标签云

微信群

扫码加入我们

WeChat QR Code

This question already has an answer here:

How can I check if a checkbox is checked via jQuery?

Can I just add an ID or class to the element and do this?

if($('#element').val() == 1) { 
  //do stuff 
}


user2864740 Not really see the comment and the statement before that. For your proof test it against older version of jquery <=1.5 or so

2018年06月20日30分43秒

user2864740 Sorry, really sleepy. :P Either way, yeah, in jQuery < 1.6, there was no .prop() so .attr() did retrieve DOM properties back then.

2018年06月20日30分43秒

Also older version of jq that doesn't support prop used to make up for setting property for standalone attributes.

2018年06月20日30分43秒

user2864740 Here you go one with version 1.5 jsfiddle.net/tgY2Y

2018年06月20日30分43秒