您好,欢迎来到码863代码分享网! 请[登录] / [注册]

jQuery 中 attr 和 prop 方法的区别

编辑

根据官方的建议:具有 true 和 false 两个属性的属性,如 checked, selected 或者 disabled 使用prop(),其他的使用 attr()

To retrieve and change DOM properties such as the checked, selected, or disabled state of form elements, use the .prop() method.


经验  做项目时记得用prop('checked',true)设置状态时生效



具有 true 和 false 两个属性的属性,如 checked, selected 或者 disabled 使用prop(),其他的使用 attr(),具体见下表:



CopyRight 2002~2023 精通2100网 联系邮箱:qqtxt@163.com
版权所有:精通2100网 湘ICP备2023018646号-1
MYSQl共执行 3 个查询,用时 0.052474975585938 秒,PHP脚本用时 0.056525 秒,占用内存 0.512 MB,Gzip 已启用