<head>
<link href="foo.css" rel="stylesheet" type="text/css" />
&l开发者_运维知识库t;/head>
can I via jquery change the href of this link from foo.css
to bar.css
$('link[href="foo.css"]').attr('href','bar.css');
have fun
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");
});
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');
精彩评论