用JS怎么改变样式。。在线等候 document.getElementById('div').style.class='' 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我按你的方法 点不出class来啊 我自己用的 function show1() { getmil.className="affairlab2"; sendmail.className="affairlab1"; } 点击后改变div的className<!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=gb2312" /><title>无标题文档</title><style type="text/css">.normal, .normal a{ color:#0000FF;}.onclick, .onclick a{ color:#008800;}</style><script type="text/javascript">function $(id){ return document.getElementById(id);}window.onload = function(){ var div = [$("div1"), $("div2"), $("div3")]; for(var i=0; i<div.length; i++){ div[i].onclick = function(){ for(var j=0; j<div.length; j++){ div[j].className = "onclick"; }; }; }};</script></head><body><div id="div1" class="normal">文字 <a href="#">链接</a></div><div id="div2" class="normal">文字 <a href="#">链接</a></div><div id="div3" class="normal">文字 <a href="#">链接</a></div></body></html> 在 div的 onmouseout 事件里再写一次 onclik 事件 所执行的代码 <!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=gb2312" /><title>无标题文档</title><style type="text/css">.noclick, .noclick a{ color:#0000FF;}.on_click, .on_click a{ color:#ff0000;}</style><script type="text/javascript">function show1(_this){ var obj =_this.parentNode.parentNode.getElementsByTagName("div"),j=obj.length;alert for (var i=0;i<j;i++) obj[i].className = "noclick"; _this.parentNode.className = "on_click";} </script></head><body><div id="getmil" class="noclick">getmil <a href="#" onclick=show1(this)>get</a></div><div id="mil" class="noclick">mil <a href="#" onclick=show1(this)>input</a></div><div id="sendmail" class="noclick">sendmail <a href="#" onclick=show1(this)>send</a></div></body></html> document.getElementById('div').className='' <body><div class=""><div id="getmil" class="noclick">getmil <a href="#" onclick=show1(this)>get</a></div><div id="mil" class="noclick">mil <a href="#" onclick=show1(this)>input</a></div><div id="sendmail" class="noclick">sendmail <a href="#" onclick=show1(this)>send</a></div></div></body>在你的基础上 外面加个DIV 呢 怎么改啊 obj.style.cssText = "color:red;"; <script>function changech(a){var i=1for(i=1;i<5;i++){var b='c'+i;var c='d'+i;if(a!=b){document.getElementById(b).style.background='url(images/01.gif) repeat-x';document.getElementById(b).style.color='#5c5c5c';document.getElementById(c).style.display='none';}else{document.getElementById(b).style.background='url(images/bar_bg.gif) repeat-x';document.getElementById(b).style.color='#ff0000';document.getElementById(c).style.display='block';}}}</script>这就是一个div控制三个div的JavaScript <!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=gb2312" /><title>无标题文档</title><style type="text/css">.noclick, .noclick a{ color:#0000FF;}.on_click, .on_click a{ color:#ff0000;}</style><script type="text/javascript">function show1(_this){ var obj =_this.parentNode.parentNode.getElementsByTagName("div"),j=obj.length;alert for (var i=0;i<j;i++) obj[i].className = "noclick"; _this.parentNode.className = "on_click";} </script></head><body><div><div><div><div><div><div><div id="getmil" class="noclick">getmil <a href="#" onclick=show1(this)>get</a></div><div id="mil" class="noclick">mil <a href="#" onclick=show1(this)>input</a></div><div id="sendmail" class="noclick">sendmail <a href="#" onclick=show1(this)>send</a></div></div></div></div></div></div></div></body></html> 小女子请教 jquery lazyload 怎么设置占位图片大小呀 感激涕淋 getelementbyid动态获取id的问题 js 点击链接后销毁当前页面后在转到新页面 增加一行UL,怎么让它产生序号?并且这里删除事件怎么写? 这个函数怎么写,请高手帮帮忙, 简单的焦点问题 正则表达式里如何取出一个数字,具体见内! 请教几个小问题~~~~ 如何将鼠标设为无效状态? window中的帮助文件里的这种效果是怎样做出来的. 一个折叠菜单,有点缺陷~~, 高分 求解~~ JS 日期控件 与 相减
我自己用的 function show1()
{
getmil.className="affairlab2";
sendmail.className="affairlab1";
}
<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
.normal, .normal a{
color:#0000FF;
}
.onclick, .onclick a{
color:#008800;
}
</style>
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}
window.onload = function(){
var div = [$("div1"), $("div2"), $("div3")];
for(var i=0; i<div.length; i++){
div[i].onclick = function(){
for(var j=0; j<div.length; j++){
div[j].className = "onclick";
};
};
}
};
</script>
</head><body>
<div id="div1" class="normal">文字 <a href="#">链接</a></div>
<div id="div2" class="normal">文字 <a href="#">链接</a></div>
<div id="div3" class="normal">文字 <a href="#">链接</a></div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
.noclick, .noclick a{
color:#0000FF;
}
.on_click, .on_click a{
color:#ff0000;
}
</style>
<script type="text/javascript">function show1(_this){
var obj =_this.parentNode.parentNode.getElementsByTagName("div"),j=obj.length;alert
for (var i=0;i<j;i++)
obj[i].className = "noclick";
_this.parentNode.className = "on_click";
} </script>
</head><body>
<div id="getmil" class="noclick">getmil <a href="#" onclick=show1(this)>get</a></div>
<div id="mil" class="noclick">mil <a href="#" onclick=show1(this)>input</a></div>
<div id="sendmail" class="noclick">sendmail <a href="#" onclick=show1(this)>send</a></div>
</body>
</html>
<body>
<div class=""><div id="getmil" class="noclick">getmil <a href="#" onclick=show1(this)>get</a></div>
<div id="mil" class="noclick">mil <a href="#" onclick=show1(this)>input</a></div>
<div id="sendmail" class="noclick">sendmail <a href="#" onclick=show1(this)>send</a></div></div></body>在你的基础上 外面加个DIV 呢 怎么改啊
<script>
function changech(a){
var i=1
for(i=1;i<5;i++){
var b='c'+i;
var c='d'+i;
if(a!=b){
document.getElementById(b).style.background='url(images/01.gif) repeat-x';
document.getElementById(b).style.color='#5c5c5c';
document.getElementById(c).style.display='none';
}
else{
document.getElementById(b).style.background='url(images/bar_bg.gif) repeat-x';
document.getElementById(b).style.color='#ff0000';
document.getElementById(c).style.display='block';
}
}}
</script>
这就是一个div控制三个div的JavaScript
<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
.noclick, .noclick a{
color:#0000FF;
}
.on_click, .on_click a{
color:#ff0000;
}
</style>
<script type="text/javascript">function show1(_this){
var obj =_this.parentNode.parentNode.getElementsByTagName("div"),j=obj.length;alert
for (var i=0;i<j;i++)
obj[i].className = "noclick";
_this.parentNode.className = "on_click";
} </script>
</head><body>
<div>
<div>
<div>
<div>
<div>
<div>
<div id="getmil" class="noclick">getmil <a href="#" onclick=show1(this)>get</a></div>
<div id="mil" class="noclick">mil <a href="#" onclick=show1(this)>input</a></div>
<div id="sendmail" class="noclick">sendmail <a href="#" onclick=show1(this)>send</a></div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>