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
Hello!
Adding attribute via javascript:
var myDiv= document.getElementsByClassName("first-div")[0]; var myp= myDiv.children[0]; nyp.setAttribute('myAttribute','valueForAttribute');
getting the attribute via javascript:
console.log(myp.getAttribute('myAttribute'));