jQuery-按属性选择? [英] JQuery - Select by attribute?
本文介绍了jQuery-按属性选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这在Opera中有效,但显然没有其他作用.
This works in Opera but apparently nothing else.
HTML
<input type="checkbox" name="iphone" value="checked" checked="checked" />
<input type="checkbox" name="photocart" value="checked" checked="checked" />
JS
$("input[name=iphone]").attr('checked', 'checked');
$("input[name=photocart]").attr('checked', 'checked');
$("input[name=iphone]").attr('disabled', 'disabled');
$("input[name=photocart]").attr('disabled', 'disabled');
我也尝试了以下方法,但无济于事.
I have also tried the following to no avail.
$("input[name|=iphone]").attr('checked', 'checked');
$("input[name|=photocart]").attr('checked', 'checked');
$("input[name|=iphone]").attr('disabled', 'disabled');
$("input[name|=photocart]").attr('disabled', 'disabled');
$("[name=iphone]").attr('checked', 'checked');
$("[name=photocart]").attr('checked', 'checked');
$("[name=iphone]").attr('disabled', 'disabled');
$("[name=photocart]").attr('disabled', 'disabled');
$("[name|=iphone]").attr('checked', 'checked');
$("[name|=photocart]").attr('checked', 'checked');
$("[name|=iphone]").attr('disabled', 'disabled');
$("[name|=photocart]").attr('disabled', 'disabled');
他们当中的任何一个都没有喜悦.关于如何进行此操作有任何想法吗?
No joy on any of them. Any ideas on how I can get this going?
-Epic复制HTML SORRY失败!
EDIT :- Epic failed on the copying of the HTML SORRY!
推荐答案
您可以这样指定:
$('input[name=hosting][checked]')
有关更多信息,请参见 Jquery多重选择器页面.
See the Jquery multiple selector page for more info.
这篇关于jQuery-按属性选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文