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
Post a Comment