Changing a stylesheet using jQuery

前端 未结 4 892
粉色の甜心
粉色の甜心 2020-12-21 02:38

How can I change a stylesheet using jquery in div tag on html? or what is the jquery code for changing stylesheets?

in javascript, we use the below code :

         


        
4条回答
  •  抹茶落季
    2020-12-21 03:03

    I use this code to enable or disable a stylesheet based on a page.

     $(document).on('pagebeforeshow', function () {
            var URL = $.mobile.path.parseUrl(window.location).toString().toLowerCase();
    
            if (URL.indexOf("/investment.aspx") > -1 ||
                URL.indexOf("/employees.aspx") > -1) {
                $("link[href^='../../Public/LongLabels.css']").attr("media", "all");
            }
            else {
                $("link[href^='../../Public/LongLabels.css']").attr("media", "not all");
            }
        });
    

提交回复
热议问题