Monday, November 9, 2009

changing CSS class name of an html tag through javascript.

if we want to change the class name from "abc" to "xyz" of a div tag having attribute id="a" through javascript and these classes are defined in stylesheet then following is the javascript code.

javascript code:

function ChangeClass(id,class)
{
document.getElementById(id).className=class;
}

ChangeClass('a','xyz');

No comments:

Post a Comment