How to Remove an Attribute With JavaScript
Style attributes set up your website's layout. You can dynamically control the website layout using JavaScript coding. Removing an attribute involves setting that attribute to a zero-length string. The attribute style clears, so the Web page element sets to the default setting. You can dynamically change any attribute style for any Web element.
Instructions
-
-
1
Right-click the HTML file you want to edit and select "Open With." Double-click the HTML editor you want to use to set up the JavaScript.
-
2
Type the following code in the body of the HTML file:
<script type="text/javascript"> </script>
These two tags tell the browser to run JavaScript code when the page loads.
-
-
3
Type the following code within the JavaScript tags to edit and clear an attribute:
document.getElementById("elementname").style.border = "";
Replace "elementname" with the HTML element you want to edit. In this example, the element's border is cleared. You can use any of the attribute styles included with HTML elements.
-
1