setAttribute()   是用于设置自定义属性的方法,有两个参数,第一个是属性名,第二个是属性值,

    添加时必须用引号括起来:

setAttribute   和    getAttribute  的用法

 

 

 此时的box就加上了一个自定义属性名和属性值,可以根据需要赋取

setAttribute   和    getAttribute  的用法

 

 

 

 getAttribute 方法用于拿到设置的自定义属性的属性值,唯一一个参数就是搜索的自定义属性名(也要用引号包起来):

setAttribute   和    getAttribute  的用法

 

 setAttribute   和    getAttribute  的用法

 

removeAttribute:

 

相关文章:

  • 2022-12-23
  • 2021-04-05
  • 2021-11-11
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案