tea_year 2015年08月05日
js CSS 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>树形菜单</title>
<style type="text/css">
body{
font-size:13px;
}

a{
color:black;
text-decoration:none;
}

img{
border:none;
}

#pictures,#art{
list-style:none;
display:block;
}
</style>
<script language="javascript">
function showArt(){
var status = document.getElementById("art").style.display;
alert(status);
if(status == "block")
document.getElementById("art").style.display = "none";
else
document.getElementById("art").style.display = "block";
}

function showPictures(){
var status = document.getElementById("pictures").style.display;
if(status == "block")
document.getElementById("pictures").style.display = "none";
else
document.getElementById("pictures").style.display = "block";
}

function addNode(){
var content = document.getElementById("content").value;
var ul = document.createElement("ul");
ul.innerHTML = "<a href='javascript:show"+ content +"()'><img src='images/fclose.gif'>"+ content +"</a>";
document.getElementById("tree").appendChild(ul);
}

// 删除节点的逻辑
function deleteLast(){
var father = document.getElementById("tree");
var last = father.lastChild;
father.removeChild(last);
}
</script>
</head>

<body>
<div id="tree">
<b><img src="images/fold.gif">树形菜单</b>
<ul>
<a href="javascript:showArt()"><img src="images/fclose.gif">文学艺术</a>
</ul>
<ul id="art">
<li><img src="images/doc.gif">先锋写作</li>
<li><img src="images/doc.gif">小说散文</li>
<li><img src="images/doc.gif">精彩博文</li>
</ul>
<ul>
<a href="javascript:showPictures()"><img src="images/fclose.gif">贴图专区</a>
</ul>
<ul id="pictures">
<li><img src="images/doc.gif">我的相册</li>
<li><img src="images/doc.gif">风景名胜</li>
<li><img src="images/doc.gif">古香古韵</li>
</ul>
</div>
<br />
<br />
节点内容:<input type="text" id="content" /><input type="button" value="添加节点" onclick="addNode()"/><input type="button" value="删除最后节点" onclick="deleteLast()" />
</body>
</html>
...全文
66 点赞 收藏 3
写回复
3 条回复

还没有回复,快来抢沙发~

发动态
发帖子
JavaScript
创建于2007-09-28

5.1w+

社区成员

22.3w+

社区内容

Web 开发 JavaScript
社区公告
暂无公告