Remove background color/images for all elements with jQuery

后端 未结 3 1125
天命终不由人
天命终不由人 2021-01-11 11:25

Is there a simple way to use jQuery to remove all background styles on a page? Specifically, need to remove background color and images.

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-11 12:19

    Real simple with jQuery...

    $('*').css('background', 'transparent');
    

    jsFiddle.

    If you didn't have jQuery at your disposal...

    var allElements = document.getElementsByTagName("*");
    
    for (var i = 0, length = allElements.length; i < length; i++) {
        allElements[i].style.background = "none";
    }
    

    jsFiddle.

提交回复
热议问题