attribute change css code example

Example 1: javascript change attribute

var element = document.getElementById("elemId");
element.setAttribute("attributeName", "value");

Example 2: target css by form name

tag[name="nameofthetag"] {
	//style your html tag
}

Example: 
<input type="submit" value="Go" name="goButton">
input[name="goButton"] {
  background: red;
}

Example 3: how to give css style in javascript

document.getElementById("myH1").style.color = "red";

Example 4: javascript change color

var span = document.getElementsByTagName("span")[0];
span.style.color = "red";

Tags:

Css Example