Javascript,Jquery:通过两个属性获取元素?
HTML:Javascript,Jquery:通过两个属性获取元素?,javascript,jquery,Javascript,Jquery,HTML: 请帮忙 您的名称值中缺少了[],它应该是name=“shape[]” $('form#u filter input[name=“shape[]”][value=Round]).prop('checked',true) 您的名称值中缺少了[],它应该是name=“shape[]” $('form#u filter input[name=“shape[]”][value=Round]).prop('checked',true) 您应该在选择器中使用引号,即: $('#form_fil
请帮忙 您的名称值中缺少了
[]
,它应该是name=“shape[]”
$('form#u filter input[name=“shape[]”][value=Round]).prop('checked',true)代码>
您的名称值中缺少了[]
,它应该是name=“shape[]”
$('form#u filter input[name=“shape[]”][value=Round]).prop('checked',true)代码>
您应该在选择器中使用引号,即:
$('#form_filter input[name=shape][value=Round]').prop('checked', true);
或:
并说明以下情况:
属性:属性名称
值:属性值。可以是有效标识符,也可以是
带引号的字符串
在上进行测试。您应该在选择器中使用引号,即:
$('#form_filter input[name=shape][value=Round]').prop('checked', true);
或:
并说明以下情况:
属性:属性名称
值:属性值。可以是有效标识符,也可以是
带引号的字符串
在.[name^=shape]
上测试以扩展Mohamed的注释-您的输入名称不是shape,而是shape[]@KunalMukherjee您不应该通过编辑来回答问题或更改代码-现在问题没有意义,因为代码可以扩展Mohamed的注释-您的输入名称不是shape,而是shape[]@KunalMukherjee您不应该通过编辑来回答问题或更改代码-现在,随着代码的运行,问题变得毫无意义
$('#form_filter input[name="shape[]"][value="Round"]').length === 1 // true
$('#form_filter input[name="shape[]"][value="Round"]').prop('checked', true); // checks your specific checkbox