split - Jquery multiple classes with .addClass dynamically -


i need use .addclass on list of classes, function classlist gives me array. .addclass doesn't work array work if write multiple classes, ('.class1, class2, class3'). there way convert .classlist array string can give .addclass. need classlist dynamically hence can't enter them manually...

thanks

var classlist = $('#postitus').attr('class').split(/\s+/).join('.'); $(classlist).addclass('active'); 

var classlist = $('#postitus').attr('class').split(/\s+/);  $.each(classlist,function(ind,val){    $('.' +val).addclass('active'); } ); 

Comments

Popular posts from this blog

python 3.x - Mapping specific letters onto a list of words -

javascript - jquery or ashx not working -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -