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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -