以下两种方法等价:
<input id="test-radio" type="radio" name="test" checked value="1">
<input id="test-radio" type="radio" name="test" checked="checked" value="1">
attr()和prop()对于属性checked处理有所不同:
var radio = $('#test-radio');
radio.attr('checked');
radio.prop('checked');
prop()返回值更合理一些,不过用is()方法判断更好
var radio = $('#test-radio');
radio.is(':checked');
类似的还有 is(":selected")
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)