Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get the classname of an element

Status
Not open for further replies.

BennySHS

Programmer
Mar 15, 2005
32
DE
Hi there !

I'm just experementing with my first js-navi and got a little problem.
I'm using the following code to set the class:

document.getElementById(id).className="showmenu";

But how can I find out which class the element currently has ?
Hope you can help me out,
thx a lot,
greets,
ben
 
That's the other way around. className is read/write.
[tt] var itsclassname=document.getElementById(itsid).className[/tt]
 
Hi!

duh, i tried that and it didn't worked - perhaps i had brackets afeter the className or so :/

Thanks a lot!
greets,
ben
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top