jquery的prop()和attr()

jQuery1.6以后prop()和attr()的应用场景如下:

第一原则:只添加属性名称该属性就会立即生效应该使用prop();

第二原则:只存在true/false的属性应该使用prop();

设置disabled和checked这些属性,应该使用prop()方法,而不是使用attr()方法。

For example, selectedIndextagNamenodeNamenodeTypeownerDocumentdefaultChecked, and defaultSelected should be retrieved and set with the .prop() method. 

参见http://api.jquery.com/attr/

原文地址:https://www.cnblogs.com/fanxiaopeng/p/3558795.html