jquery attr及prop方法

项目中用到checkbox

attr("checked",true),执行此方法后复选框前面打了勾

之后 removeAttr("checked")

再次执行attr("checked",true),复选框前面不打勾了,查看元素属性,checked="checked",但是前台就是没有打勾。

查阅资料,貌似是浏览器的相关BUG,有人建议使用prop

即:prop("checked",true)

改之,生效

特此记之

猜你喜欢

转载自leozam.iteye.com/blog/2375160