简体   繁体   中英

jQuery change link href in the body of the page

I am looking for a way to change the href of the code below:

<link rel="stylesheet" type="text/css" href="theme1.css">

For example from:

<link rel="stylesheet" type="text/css" href="theme1.css">

to:

<link rel="stylesheet" type="text/css" href="theme2.css">

This is currently not in the head of the page but in the body. And I only want to target a specific one.

How can I change it using jQuery?

您可以像这样使用attrprop方法:

$('link[href*="theme1.css"]').attr('href','theme2.css');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM