1、$('obj').prop('checked',true)

2、

$(':checkbox').each(function(){

    this.checked=true;

    })

为什么:attr为失效?因为checked属于为原型对象的属性。而attr在remove原型对象时会出错。原型对象指的是自身自带的,无法移除。prop会忽略这个错误。而attr操作的是普通非原型对象(可移除)。js 的dom对象属性是可以随意增加的。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-25
  • 2021-10-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-28
  • 2022-12-23
  • 2022-12-23
  • 2021-06-27
  • 2022-12-23
  • 2021-09-16
相关资源
相似解决方案