简体   繁体   中英

JQuery button to disable CSS across entire website?

I want to make these buttons which enable/disable the css across an entire website I am making. I am trying to make it so when a user clicks the button to disable/enable the css, it does so across all the webpages of the site and not just for the page a user is on.

So far, my code to enable/disable the css is as follows

<script>
$("#text-only").click(function () { jQuery('#mainStyleSheet').remove();}); 
$("#renable-style").click(function () {$('head').append('<link href="css/style.css" rel="stylesheet" id="mainStyleSheet" />');});
</script>

Any ideas?

{$('head').append('<link href="css/style.css" rel="stylesheet" id="mainStyleSheet" />');}); 

代替

{$('head').html('<link href="css/style.css" rel="stylesheet" id="mainStyleSheet" />');});

我认为您应该为网页中创建的每个对象添加一个css类。在该类中进行所有更改。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM