【问题标题】:jQuery select where attribute = valuejQuery选择其中属性=值
【发布时间】:2009-11-19 10:59:06
【问题描述】:

我正在尝试选择值等于动态值的输入

trimmed = jQuery.trim(a);
preSelectedCheckBox = $(this).find("input[value=" + trimmed + "]"); 

元素存在,但我一直没有返回任何值。 ($(preSelectedCheckBox).length = 0)

【问题讨论】:

    标签: jquery jquery-selectors


    【解决方案1】:

    你只是缺少封闭的单引号吗?

    trimmed = jQuery.trim(a);
    preSelectedCheckBox = $(this).find("input[value='" + trimmed + "']");
    

    【讨论】:

      【解决方案2】:
      preSelectedCheckBox = $(this).find("input[value=" + trimmed + "]");
      

      忘记值周围的''

      【讨论】:

        猜你喜欢
        • 2014-03-28
        • 2023-03-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-11-30
        • 2015-09-21
        • 2010-10-19
        相关资源
        最近更新 更多