Html/[removed] Add Attribute to an HTML Control

前端 未结 5 635
悲哀的现实
悲哀的现实 2021-01-15 00:49

Need: Find a way to add a valid tag/attribute/property to a normal html control.

What I have is some javascript/jquery adding a click event to a link that will show

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-15 01:34

    The way you add an attribute to an html control is by using the element.setAttribute("attributeName", "attributeValue") where "element" is the element you want to add the attribute to.

    To get an attribute you use getAttribute("attributeName");

提交回复
热议问题