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

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -