如果頁面名爲mypage.html,我想讓下面的javascript更新特定的css鏈接bootstrap.min.js。
我該怎麼做?如何讓JavaScript修改基於頁面名稱的CSS鏈接?
<html>
<head>
<link rel="stylesheet" type="text/css" href="/css/bootstrap377.min.css"/>
<link rel="stylesheet" type="text/css" href="/css/some_other_stylesheet.css"/>
<script type="text/javascript">
var filename = location.href.split("/").slice(-1);
if (filename == "mypage.html") {
HOW DO I DO THIS: update the above stylesheet link to be bootstrap400.min.css (or should this script be before the css link?)
}
</script>
</head>
<body>
this is a test
</body>
</html>
不能從HTML – Nelu
我的例子已經訪問訪問文件名的文件名,我需要的腳本來修改CSS鏈接 – user3302169