jquery中的prop和attr

来源:互联网 发布:淘宝网店客服合肥 编辑:程序博客网 时间:2024/05/22 06:09

在项目中使用到checkbox,radio和select这样的元素,选中属性对应“checked”和“selected”,在jquery中使用prop方法代替attr方法才能得到正确的结果

$("#radio").prop("checked") == false//多次使用attr会报错,不知道为什么$("#radio").attr("checked") == "checked"
原创粉丝点击