我用的方法不知道哪里错了.行不通
<html>
<head>
<title>我的主页</title>
<style type="text/css">
div{width:300px;margin:55px auto;border:1px solid #ccc;}
ul{
list-style:none;
}
ul li{
background:url(list.gif) 3px center no-repeat;
height:25px;
border-bottom:1px solid #ccc;
line-height:25px;
padding-left:14px;
}
h3{
background:#c00 url(list.gif) 0 center no-repeat;
font-size:12px;
height:25px;
line-height:25px;
padding-left:15px;
}
*{margin:0;padding:0;}
a{font-size:13px;text-decoration:none;}
#paragraph{width:500px;background:orange;border:1px solid #c00;line-height:30px;}
</style>
</head>
<body>
<ul id="list">
<li><a href="http://www.qq.com">我在测试</a></li>
<li><a href="http://www.qq.com">我在测试</a></li>
<li><a href="http://www.qq.com">我在测试</a></li>
<li><a href="http://www.qq.com">我在测试</a></li>
<li><a href="http://www.qq.com">我在测试</a></li>
<li><a href="http://www.qq.com">我在测试1</a></li>
</ul>
<p id="paragraph">我的段落文本!</p>
<div id="divs">
<h3>导航栏</h3>
</div>
<p>
<label for="user">用户名:</label>
<input type="text" size="20" id="user" value="请输入用户名!" name="" />
</p>
<script type="text/javascript">
var paragraph = document.getElementById("list");
removeChild(paragraph.childNodes.length.lastChild)
</script>
</body>
</html>
<html>
<head>
<title>我的主页</title>
<style type="text/css">
div{width:300px;margin:55px auto;border:1px solid #ccc;}
ul{
list-style:none;
}
ul li{
background:url(list.gif) 3px center no-repeat;
height:25px;
border-bottom:1px solid #ccc;
line-height:25px;
padding-left:14px;
}
h3{
background:#c00 url(list.gif) 0 center no-repeat;
font-size:12px;
height:25px;
line-height:25px;
padding-left:15px;
}
*{margin:0;padding:0;}
a{font-size:13px;text-decoration:none;}
#paragraph{width:500px;background:orange;border:1px solid #c00;line-height:30px;}
</style>
</head>
<body>
<ul id="list">
<li><a href="http://www.qq.com">我在测试</a></li>
<li><a href="http://www.qq.com">我在测试</a></li>
<li><a href="http://www.qq.com">我在测试</a></li>
<li><a href="http://www.qq.com">我在测试</a></li>
<li><a href="http://www.qq.com">我在测试</a></li>
<li><a href="http://www.qq.com">我在测试1</a></li>
</ul>
<p id="paragraph">我的段落文本!</p>
<div id="divs">
<h3>导航栏</h3>
</div>
<p>
<label for="user">用户名:</label>
<input type="text" size="20" id="user" value="请输入用户名!" name="" />
</p>
<script type="text/javascript">
var paragraph = document.getElementById("list");
removeChild(paragraph.childNodes.length.lastChild)
</script>
</body>
</html>
var i = paragraph[paragraph.length-1]
i.parentNode.removeChild(i)
var ochild=list.children[list.children.length-1];
if(ochild)
list.removeChild(ochild);
else
alert( "没有可删除的Li ");
}
钻石,我问一下,改成这样可以不?
paragraph.removeChild(i)