How to change any attribute of a HTML element

PHOTO EMBED

Fri Aug 16 2024 01:01:50 GMT+0000 (Coordinated Universal Time)

Saved by @shawnclevinger

<html>	
   
   <input id="contact" name="address">
 
 <script>
 
    document.getElementById("contact").attribute = "phone";
	
    //ALTERNATIVE METHOD TO CHANGE
    document.getElementById("contact").setAttribute('name', 'phone');	
 
  </script>
 
</html>
content_copyCOPY

https://www.thiscodeworks.com/how-to-change-any-attribute-of-a-html-element-html-javascript-jsfunctions-dom-dommanipulation/5e2e022d77696f00148a2077