Insert multiple attributes into html tag using JavaScript and not between tags
- by WilliamK
From a previous quest we asked about inserting a new attribute into a html tag and the code below does the job nicely, but how should it be coded to add multiple attributes, for example changing..
<body bgcolor="#DDDDDD">
to...
<body bgcolor="#DDDDDD" topmargin="0" leftmargin="0">
The code that works for a single attribute is...
document.getElementsByTagName("body")[0].setAttribute("id", "something");
How to modify this for inserting multiple attributes?