【发布时间】:2010-11-01 04:00:26
【问题描述】:
我不想使用 style.css 中的样式,所以我决定从 DOM 中删除 style.css。这在 Firefox 和 IE8 中运行良好,但在 IE6 中不行:
$("LINK[href='http://www.example.com/style.css']").remove();
任何其他解决方案,使用 jQuery?
这里是示例:
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Testing</title>
<script type="text/javascript" src="path/to/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("link[href*='style.css']").remove();
});
</script>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="content">...</div>
</body>
</html>
这里是 CSS (style.css):
#content {
background-color:#333;
}
仅在 IE 中 #content 仍然是黑暗的。 :(
也许是 jQuery 的错误?
【问题讨论】:
标签: javascript jquery css dom