作者: jiake0504 链接: http://jiake0504.javaeye.com/blog/259674 发表时间: 2008年10月29日
声明:本文系JavaEye网站发布的原创博客文章,未经作者书面许可,严禁任何网站转载本文,否则必将追究法律责任!
<html>
<head>
<title>Test Clear Div's Input </title>
<script type="text/javascript">
function $(id)
{
return document.getElementById(id);
}
function clearDiv()
{
var nodes = $('div1').childNodes;
for(var i = 0 ; i < nodes.length ; i++)
{
if(nodes[i].type == 'text')
{
nodes[i].value = '';
}
}
}
</script>
</head>
<body>
<div id="div1">
<input type="button" value="btn1">
<input type="text" id="text1" value="text1">
<input type="button" value="btn2">
<input type="text" id="text2" value="text2">
<input type="text" id="text3" value="text3">
<input type="text" id="text4" value="text4">
<input type="text" id="text5" value="text5">
<input type="text" id="text6" value="text6">
</div>
<br/>
<input type="button" value="clear" οnclick="clearDiv()">
<div id="showObject">
</div>
</body>
</html>
已有 0 人发表留言,猛击->>这里<<-参与讨论
JavaEye推荐