alert the class name of an element using javascript -


i have element , want alert class attribute of element use code;

<li id="sss" class="settings" onclick="alertclassname(this)">1111</li> 

and in alertclassname function ;

function changeclass(elem) { var x = $(elem.id); alert(x.class) ; } 

it alerts undefind.

try classname instead of class.

onclick="alertclassname(this)" 

...

function alertclassname(elem) {   alert(elem.classname); } 

reference.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -