![]() |
#2
foktime2010-03-05 09:03
|

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www. <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<p id="p1"><b>hello</b>world</p>
<input type="button" value="use ranges" onclick="useRanges()">
<table border="0">
<tr>
<td>
<fieldset>
<legend>oRange1</legend>
startContainer:<input type="text" id="txtStartContainer1"><br/>
startoffset:<input type="text" id="txtStartOffset1"><br/>
endContainer:<input type="text" id="txtEndContainer1"><br/>
endoffset<input type="text" id="txtEndOffer1"><br/>
commonancestor:<input type="text" id="txtCommonAncestor1"><br/>
</fieldset>
</td>
</tr>
</table>
</html> <script>
var oP1=document.getElementById("p1");
var oHello=oP1.firstChild.firstChild.tagName;
alert(oHello);
</script>
运行结果为什么是object?<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<p id="p1"><b>hello</b>world</p>
<input type="button" value="use ranges" onclick="useRanges()">
<table border="0">
<tr>
<td>
<fieldset>
<legend>oRange1</legend>
startContainer:<input type="text" id="txtStartContainer1"><br/>
startoffset:<input type="text" id="txtStartOffset1"><br/>
endContainer:<input type="text" id="txtEndContainer1"><br/>
endoffset<input type="text" id="txtEndOffer1"><br/>
commonancestor:<input type="text" id="txtCommonAncestor1"><br/>
</fieldset>
</td>
</tr>
</table>
</html> <script>
var oP1=document.getElementById("p1");
var oHello=oP1.firstChild.firstChild.tagName;
alert(oHello);
</script>
[ 本帖最后由 H 于 2010-3-4 19:47 编辑 ]