Is it possible to add css property with jquery?

Question: Is there a way to add some css property using jquery without changing / overriding the previous value?

For example : if I want to add !importantto all the color properties applied in my stylesheet. Is it possible to do this with jquery? instead of going through each css file and putting !importantin front of each color property?

+4
source share
1 answer

You can use the entire selector ('*')with each()to scroll through each item and apply the rule !important.

$('*').each(function(){
    var c = $(this).css('color');

    $(this).attr('style', 'color: '+c+' !important;');       
});

, attr . .

jsfiddle.

+3

All Articles