Hi Friends..
I have a set of of div tags with different ID.
I want to give them a class name during page loading dynamically according to IDs.
How to do that,can u please help!! I am beginer in Javascript.
Thanx,
Prabir
| SitePoint Sponsor |
Hi Friends..
I have a set of of div tags with different ID.
I want to give them a class name during page loading dynamically according to IDs.
How to do that,can u please help!! I am beginer in Javascript.
Thanx,
Prabir


Code:document.getElementById("your-id").className = "your-class";
Birnam wood is come to Dunsinane
Thx AutisticCuckoo..
Its working beautifully.



setting attributes, like class names, is typically done like this...
however since IE has to be different - the way AutisticCuckoo pointed out has to be used for IE to change classes properly.Code:document.getElementById("your-id").setAttribute("class", "your-class");
Bookmarks