[英]Remove or Disabled style sheet from a page linked though link tag
我正在尝试禁用我的页面中使用链接标记链接的两个CSS链接。
<div class="ExportedContent">
<link href="//thisismysite/common14/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link rel="stylesheet" href="//thisismysite/common14/stylesheet_2014.css" type="text/css">
</div>
我有以下代码来删除此链接不起作用
<script>
$(document).ready(function(){
$('link[href="https://grants.nih.gov/common14/css/bootstrap.min.css"]').remove();
$('link[href="https://grants.nih.gov/common14/stylesheet_2014.css"]').remove();
});
</script>
到目前为止,这没有任何想法
html
link
元素和js
选择器似乎具有不同的href
属性值?
尝试使用以选择器.removeAttr()
结尾的属性
$("link[href$='bootstrap.min.css'], link[href$='stylesheet_2014.css']")
.removeAttr("href")
您的链接以//domain
开头
您的选择器以https://domain
开头
那是不匹配的
您可以使用[name $ =” value”]选择器来匹配以给定字符串结尾的内容。 此比较区分大小写。
您可以使用而不是删除链接标签的另一件事是document.styleSheets
并且我可以说链接标签位于div标签内看起来很奇怪...
document.styleSheets[0].disabled = true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.