jQuery – enable/disable all style sheets on page on click

后端 未结 6 1207
情书的邮戳
情书的邮戳 2020-12-06 06:05

Is it possible to detect all style sheets on the current page with a click of a ‘disable/enable CSS’ button and disable them on the first click so none of the styling applie

6条回答
  •  余生分开走
    2020-12-06 06:49

    Here is a rough example that relies on assigning an id to a style and then removing and restoring it using a variable.

    HTML

    
    
    Something
    Click to Remove
    Click to Restore

    Javascript

    var css = $("#test");
    $("#remove").click(function(){
        css.remove();
    });
    
    $("#restore").click(function(){
        $("head").append(css);
    });
    

    Working Example http://jsfiddle.net/Fwhak/

提交回复
热议问题