Jquery获取checkbox属性checked为undefined

Laughing
2017-06-30 / 1 评论 / 1,573 阅读 / 搜一下 / 正在检测是否收录...
温馨提示:
本文最后更新于2025年04月04日,已超过45天没有更新,若内容或图片失效,请留言反馈。

As of jQuery 1.6, the .attr() method returns undefined for attributes that have not been set. In addition, .attr() should not be used on plain objects, arrays, the window, or the document. To retrieve and change DOM properties, use the .prop()method.

v1.6以后attr(‘checked’)就返回checkedundefined,

v1.6以前返回truefalse,

v1.6以后可以使用is(':checked')或者.prop('checked')来返回truefalse

0

评论 (1)

取消
  1. 头像
    李森
    MacOS · Safari

    呵呵

    回复
  2. 头像
    李森
    MacOS · Safari

    呵呵

    回复
  3. 头像
    tt
    MacOS · Google Chrome

    找了很久 414

    回复
  4. 头像

    […] 前一篇我们介绍了log4net写日志到文件的方法,具体可以参考。  配置log4net写日志到文件,这一篇我们继续介绍log4net写日志到数据库的方法。 […]

    回复