注册 登录
编程论坛 ASP技术论坛

document.stylesheets的removerule方法

yqiong 发布于 2007-10-10 14:45, 999 次点击
对于document.stylesheets的remove方法不了解,下面这程序不能删除样式表规则?
<html>
<head>
<title>无标题文档</title>
<style>p.p1{ background-color:#FF0000;font-size:22px;_
font-family:"方正舒体"; font-weight:100; }</style>
<script language="vbscript">
sub remove()
{
document.stylesheets[0].removerule 0
}
end sub
</script></head>
<body><p class=p2 style=" background-color:#FF0000;font-size:22px; font-family:"方正舒体"; font-weight:100;"> hello,this is a example of stylesheets</p>
<form>
<input type="button" value="按我取消下行背景设置" onClick="remove()">
<p class=p1> hello,this is a example of stylesheets</p>
</body>
</html>

[此贴子已经被作者于2007-10-10 14:50:29编辑过]

2 回复
#2
yqiong2007-10-10 15:06
<STYLE>
P {color:green;}
</STYLE>
<SCRIPT>
function removeTheRule() {
var iSheets = document.styleSheets.length;
var iRules = document.styleSheets[iSheets-1].rules.length;
if (1 < iRules) {
document.styleSheets[iSheets-1].removeRule(1);
}
}
</SCRIPT>
<P>This text has the new style applied to it.</P>
<BUTTON onclick="removeTheRule()">Remove the new rule.</BUTTON>
也没显示
#3
yqiong2007-10-11 13:50

各位大侠,帮忙看看咯,谢谢啦

1