Toggle between two stylesheets

后端 未结 7 1660
北荒
北荒 2020-12-11 03:38

I am trying to add in a very simple method of switching between 2 stylesheets.

I can get the stylesheet to fire on click but not able to toggle it back to its origin

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-11 03:58

    You can try something like this :

    let test = true;
    $('#css_toggle').click(function() {
      if(test) {
        $('link.sty').attr("href","style.css");
        test = false;
      } else {
        $('link.sty').attr("href","style1.css");
        test = true;
      }
    });
    
    
    
    
    

提交回复
热议问题