change the href of a css link via jquery

后端 未结 3 1270
我在风中等你
我在风中等你 2020-12-03 19:35



can I via jquery change the href of this link from

相关标签:
3条回答
  • 2020-12-03 20:01

    Html:

    <head>
    <link id="test" href="foo.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        ...
    </body>​​​​​​​​​​
    

    And the jQuery:

    ​$(document).ready(function() {
        $("#test").attr("href", "bar.css");
    });​
    
    0 讨论(0)
  • 2020-12-03 20:05

    And one more

    Html:

    <head> 
    <link id="bar" href="foo.css" rel="stylesheet" type="text/css"/> 
    </head>
    

    jQuery:

    $("link[id='bar']").attr('href', 'bar.css');
    
    0 讨论(0)
  • 2020-12-03 20:15
    $('link[href="foo.css"]').attr('href','bar.css');
    

    have fun

    0 讨论(0)
提交回复
热议问题