I want to add multiple lines of CSS with JavaScript. I know I can do this:
document.getElementById(id).style.property=new style
as in:
<!DOCTYPE html>
<html>
<body>
<h1 id="id1">My Heading 1</h1>
<button type="button"
onclick="document.getElementById('id1').style.color = 'red'">
Click Me!</button>
</body>
</html>
But, the above code allows me add just a single CSS Property. If a want to add more than one property, like this:
#id1 {
color: red;
background-color: beige;
padding-bottom: 2px;
margin: 3px;
}
How do I add all of this by not repeating:
document.getElementById(id).style.property=new style
....again and again. Thanks in advance !