You can do like this :
document.getElementByXXX --> you can put Tag,Name,Calss,ID instead of XXX
element = document.getElementById(id);
example if you want to change bg color:
window.onload = function(){
document.getElementById("your_id").style.background ="red";
}
here are some good examples:
http://xahlee.info/js/js_get_elements.html
@Raj Mehta its working:
<html>
<head>
<script>
function load(){
var myObj1 = document.getElementById("root").getElementsByClassName("xyz");
var myObj2 = document.getElementById("root").getElementsByClassName("xy");
var myObj3= document.getElementById("root").getElementsByClassName("foo2");
var myObj4= document.getElementById("root").getElementsByTagName("p");
var myObj5= document.getElementById("root").getElementsByTagName("div");
myObj1[0].style.color="red";
myObj2[0].style.color="green";
myObj3[0].style.color="skyblue";
myObj4[1].style.color="purple";
myObj5[1].style.color="blue";
}
</script>
</head>
<body onload="load()" >
<div id="root">
<div id="abc" class="xy"> 123 <div> here you combine using array[0],[1],[2]... depends on you structure</div> </div>
<p id="abc" class="xyz"> 123 </p>
<span name="span" id="foo" class="foo2"> foo3 </span>
<p id="new" name="name"> one more lvl</p>
</div>
</body>
</html>
There is no other way either this or use jquery.