<script>
window.onload=function(){
alert(document.getElementById("aaa").className);
document.getElementById("aaa").className = "red";
};
</script>
<style type="text/css">
div.green:hover{background-color:Green;}
div.red:hover{background-color:red;}
</style>
<div id="aaa">aaa</div>
===============================
这样应该是可以的吧!
window.onload=function(){
alert(document.getElementById("aaa").className);
document.getElementById("aaa").className = "red";
};
</script>
<style type="text/css">
div.green:hover{background-color:Green;}
div.red:hover{background-color:red;}
</style>
<div id="aaa">aaa</div>
===============================
这样应该是可以的吧!
解决方案 »
- 请问这个email验证有什么问题
- 请问能否将用下面方法显示的日期字体颜色设置为自己想要的颜色?
- 如何引用其它htm文件里面的表格内容?只有高手才能解决!请求高手快快帮忙!
- 一个检验表单的问题???
- 这几个函数有点不明白啊,求助,一问15分
- javaScript控制选择项的数目!怎么不起作用!
- 求助!谁能告诉我,怎样用javascript实现onchange!详细请看内容!急需!!谢谢
- [在线等]请问论坛帖子列表的前面的+号展开是怎么做的?
- 请教:类似outlook风格的WEB页面??
- 焦点移动的问题……(高分求助)!
- 请问使用JSP在Tomcat6.0.18下面获得客户端网卡的Mac
- IE7中window.open的问题
if(document.all)
{
window.style="div:hover{background-color:Green;}";
document.createStyleSheet("javascript:style");
}
else
{
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML="div:hover{ background-color:Green}";
document.getElementsByTagName('HEAD').item(0).appendChild(style);
}
}
<!--
a:hover {
text-decoration: underline;
font-family: '新細明體';
font-size: 9pt;
color: #FFFFFF;
}
.link {
font-family: '新細明體';
font-size: 9pt;
color: #DBD9FF;
text-decoration: none;
}
-->
</style>
<a href="#" target="main" class="link">STEP</a>
<script>
document.styleSheets[0].rules("a:hover").style.color="green";
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
div{width:20px;height:20px;background-color:Red;}
div:hover{background-color:Green;}
</style>
</head>
<body>
<div></div>
<script>
document.styleSheets[0].rules("div:hover").style.background="green";
</script>
</body>
</html>
element.style.hover.width = "20px";
element.style.hover.height = "20px";
element.style.hover.backgroundColor = "Red";第二个问题看来也是比较偏的,下班时结了。
var doc = document;
var div = doc.createElement("DIV");
div.id = "";
div.zIndex = "1";
div.style.left = "0px";
div.style.top = "0px";
div.style.width = "200px";
div.style.height = "200px";
div.className="aa";
div.style.position = "absolute";
div.style.backgroundColor = "#EFEFEF";
document.styleSheets[0].rules("aa:hover").style.background="green";
div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
doc.body.appendChild(div);
window.onload=function(){alert(document.styleSheets[0].rules("aa:hover").style.background)}
</script>我用了一个变换的形式,但是好象没有效果,晕!
var doc = document;
var div = doc.createElement("DIV");
div.id = "";
div.zIndex = "1";
div.style.left = "0px";
div.style.top = "0px";
div.style.width = "200px";
div.style.height = "200px";
div.className="aa";
div.style.position = "absolute";
document.styleSheets[0].rules("aa").style.background="#EFEFEF";
document.styleSheets[0].rules("aa:hover").style.background="green";
div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
doc.body.appendChild(div);
window.onload=function(){alert(document.styleSheets[0].rules("aa:hover").style.background)}
</script>这样他就有效了
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
div{width:20px;height:20px;background-color:Red;}
div:hover{}
</style>
</head>
<body>
<div style="h"></div><script>
var doc = document;
var div = doc.createElement("DIV");
div.id = "";
div.zIndex = "1";
div.style.left = "0px";
div.style.top = "0px";
div.style.width = "200px";
div.style.height = "200px";
div.className="aa";
div.style.position = "absolute";
document.styleSheets[0].rules("aa").style.background="#EFEFEF";
document.styleSheets[0].rules("aa:hover").style.background="green";
div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
doc.body.appendChild(div);
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css" id="style">
div{width:20px;height:20px;background-color:Red;}
div:hover{background-color:Green;} div.cc{background-color:blue} span{display:block; width:100px; height:20px; background:red}
span:hover{background:yellow}
</style>
</head>
<body>
<div></div>
<div class="cc"></div>
<span></span>
<script>
var styles = document.getElementById('style').innerHTML, reg01 = /[^\}]+?\}/g, cssEs = styles.match(reg01), els = [];
var reg02 = /[^,]+(?=,|\{)/g;
for(var i=0; i<cssEs.length; i++){
var ces = cssEs[i].match(reg02), css = cssEs[i].replace(/^[^\{]+?\{(.+?)\}$/,'$1');
for(var n=0; n<ces.length; n++){
var hs = ces[n].match(/[\w_]+(?=:hover)/g);
if(hs)for(var m=0; m<hs.length; m++)getEv(hs[m].replace(/^\s*?(.+)\s*?$/,'$1'), css);
}
} function getEv(hs, css){
if(/^a\./i.test(hs)) return;
var tem = hs.split('.'), elm = tem[0], cls = tem[1] || null;
var elms = document.getElementsByTagName(elm);
if(cls){
for(var n=0; n<elms.length; n++)if(elms.className == 'cls') setEv(elms[n], css);
}else{
for(var n=0; n<elms.length; n++) setEv(elms[n],css);
}
} function setEv(elm, css){
elm.css = css;
elm.onmouseover = function(){
this.style.cssText = this.css;
this.setAttribute('style', this.css);
}
elm.onmouseout = function(){
this.style.cssText = '';
this.setAttribute('style','');
}
}
</script>
</body>
</html>
type.prototype.show = function() { alert(this); }
}show(String);
show(Number);"Zswang".show();
(1234).show();
alert(function(n){ return n <= 1 ? 1 : n + arguments.callee(n - 1); }(10));