<select id='Sel' name='Sel' class='newSelOpt' onchange="display('Sel')">
<option value='a'>a</option>
<option value='b'>b</option>
<option value=c'>c</option>
<option value='d' selected>d</option>
</select>
<span style="display:none">12<%=xx %></span>通过function取到select的id
var tb = document.getElementById(scaleid);
var items = tb.getElementsByTagName("select");
var arr = items[0];
alert(arr.nextSibling.nodeType); --> 3
alert(arr.nextSibling.innerHTML); -->undefined
alert(arr.nextSibling.nodeName); -->#text
alert(arr.nextSibling.nodeValue); -->
alert(arr.nextSibling.firstChild); -->null但是取不到线面那个xx的值,怎么回事呢?
<option value='a'>a</option>
<option value='b'>b</option>
<option value=c'>c</option>
<option value='d' selected>d</option>
</select>
<span style="display:none">12<%=xx %></span>通过function取到select的id
var tb = document.getElementById(scaleid);
var items = tb.getElementsByTagName("select");
var arr = items[0];
alert(arr.nextSibling.nodeType); --> 3
alert(arr.nextSibling.innerHTML); -->undefined
alert(arr.nextSibling.nodeName); -->#text
alert(arr.nextSibling.nodeValue); -->
alert(arr.nextSibling.firstChild); -->null但是取不到线面那个xx的值,怎么回事呢?
经过试验,nodeType = 3的节点,取它的值用nodeValue可行。
另外请注意nodeType=3的节点的特殊性,是纯文本节点。
以上。