Javascript for adding a custom attribute to some elements

前端 未结 4 1620
渐次进展
渐次进展 2021-02-01 13:22

Given a section of HTML, can I selectively pick some types of elements (e.g., input) and add a custom attribute using JavaScript? I would also need to remove this attribute if i

4条回答
  •  北海茫月
    2021-02-01 14:08

    el.attribute = value
    

    is all there is to it. The attribute is created if it does not exist.

提交回复
热议问题