javascript - addclass() working in console but not working in script -


i have created div dynamically. tried add class expanded through jquery not working. tried code in console, working fine there.

code follows:

appending element name

var menuid= '#itemmenu' + indexofelement; 

and tried this

$(menuid).addclass('expanded'); 

when tried folllowing in console

e.g. $('#itemmenu5').addclass('expanded')

its working fine..

var menuid= 'itemmenu' + indexofelement; var element = document.getelementbyid(menuid); element.classname += ' expanded';   //note space 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -