当点击 "点击切换简洁版式"的时候显示蓝色, 就切换到"返回传统版式",然后点击"返回传统版式",就显示红色和"点击切换简洁版式".
怎么让它一直这样循环啊?
<!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 content="text/html; charset=gb2312" http-equiv="Content-Type">
<title>无标题文档</title>
<style type="text/css">
#kb_link{position:absolute;left:300px;top:50px;cursor:pointer;}
#red{background:red;padding:8px;}
#blue{ background:blue;padding:8px;}
</style></head>
<body>
<div id="kb_link">点击切换简洁版式<a href="">sd</a></div>
<div id="red"></div>
<div id="blue" style="display:none"></div>
<script type="text/javascript">
function removeLinks(){
var kb_links = document.getElementById("kb_link");
var removelink = kb_links.getElementsByTagName("a")[0];
kb_links.removeChild(removelink);
kb_links.lastChild.nodeValue = "点击切换简洁版式";
}
removeLinks();
function kb_link(){
var kb_link = document.getElementById("kb_link");
kb_link.onclick = function(){
document.getElementById("red").style.display = "none";
document.getElementById("blue").style.display = "block";
this.lastChild.nodeValue = "返回传统版式";
this.style.left = "880px";
this.onclick = function(){
} }
}
kb_link()
</script>
</body>
</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 content="text/html; charset=gb2312" http-equiv="Content-Type">
<title>无标题文档</title>
<style type="text/css">
#kb_link{position:absolute;left:300px;top:50px;cursor:pointer;}
#red{background:red;padding:8px;}
#blue{ background:blue;padding:8px;}
</style></head>
<body>
<div id="kb_link">点击切换简洁版式<a href="">sd</a></div>
<div id="red"></div>
<div id="blue" style="display:none"></div>
<script type="text/javascript">
function removeLinks(){
var kb_links = document.getElementById("kb_link");
var removelink = kb_links.getElementsByTagName("a")[0];
kb_links.removeChild(removelink);
kb_links.lastChild.nodeValue = "点击切换简洁版式";
}
removeLinks();
function kb_link(){
var kb_link = document.getElementById("kb_link");
kb_link.onclick = function(){
document.getElementById("red").style.display = "none";
document.getElementById("blue").style.display = "block";
this.lastChild.nodeValue = "返回传统版式";
this.style.left = "880px";
this.onclick = function(){
} }
}
kb_link()
</script>
</body>
</html>
解决方案 »
- Extjs 中 下拉框 放入grid中
- window.showModalDialog 子页面显示出现滚动条
- 关于javascript问题,,很急
- 求一正则表达式 格式化XHTML
- window.showModalDialog()可以打开一个空白窗口,并在新窗口内用document.write向模态窗口内写javascript脚本吗?
- 在线问,关于层的控制,解决马上给分
- ???我想只input的类型为text的元素定义样式怎么写
- 如何用javascript控制用户只能输入半角字符
- 请问,在客户端好不好判断上传的文件是否存在?
- 关于翻页保存多个checkbox选中记录的问题?
- iframe chrome11中如何自适应高度?
- 讨论下,javascript遇到这种数据一致性问题是否有成熟的解决方案
var kb_link = document.getElementById("kb_link");
kb_link.onclick = function(){
document.getElementById("red").style.display = "none";
document.getElementById("blue").style.display = "none";
var val=this.lastChild.nodeValue;// "返回传统版式";
if(val=="返回传统版式"){
this.lastChild.nodeValue= "点击切换简洁版式";
document.getElementById("red").style.display = "block";
}else{
this.lastChild.nodeValue="返回传统版式";
document.getElementById("blue").style.display = "block";
}
//this.style.left = "880px";
}
}改这个函数
<div id="kb_link">点击切换简洁版式</div>
<div id="red"></div>
<div id="blue" style="display:none"></div>
<script type="text/javascript">
var isRed = true;
window.onload=function(){
document.getElementById("kb_link").onclick=function(){
isRed =!isRed ;
this.innerHTML = isRed ?"点击切换简洁版式":"返回传统版式";
document.getElementById("red").style.display = isRed ?"block": "none";
document.getElementById("blue").style.display = isRed ? "none": "block";
};
};</script>