您的位置:首页 > Web前端 > Node.js

javascript的hasChildNodes()的应用

2012-12-22 23:27 405 查看


<html>

<head>

<title>getElementByName</title>

</head>

<body>

<form name="from1" action="text.html" method="post">

<input type="text" name="username" value="Id1" id="tid1" onchange="change()"/><br/>

<input type="text" name="username" value="Id2" id="tid2"/><br/>

<input type="text" name="username" value="Id3" id="tid3"/><br/>

<input type="button" name="ok" value="baocun"/>

</form>

<select name="edu" id="edu">

<option value="博士">博士...</option>

<option value="硕士">硕士...</option>

<option value="本科" selected="selected">本科...</option>

<option value="幼儿园">幼儿园...</option>

</select>

</body>

<script language="JavaScript">

//查看id="edu"的节点是否含有子节点

alert(document.getElementById("edu").hasChildNodes());

//查看id="id1"的节点是否含有子节点

alert(document.getElementById("tid1").hasChildNodes());

//hasChildNodes() 只能获取ID才能进行判断

</script>

</html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: