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

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -