Changing a stylesheet using jQuery

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

    there are better ways to do what you're asking but if you really want to remove and add a remote stylesheet with jquery you can do this:

    $('link[href^=old_css_file.css]').attr('href', '/path_to_new_css/file.css');
    

    read more about the ^= attribute selector and the attr() function

提交回复
热议问题