Changing a stylesheet using jQuery

前端 未结 4 894
粉色の甜心
粉色の甜心 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:13

    For updating full theme it's best to load a new CSS file. Easiest done on the server side but if you insist on loading dynamically:

    // Don't know jQuery, this is regular JS:
    var newCss = document.createElement('link');
    
    newCss.rel = 'stylesheet';
    newCss.type = 'text/css';
    newCss.href = '/path/to/new/cssfile.css';
    
    document.body.appendChild(newCss);
    

提交回复
热议问题