通过其他手段拿到一个控件(比如document.getElementById(...))后,可以用nodeName来获得控件的标签类型。下面是一个小例子:
<script>
window.οnlοad=function(){
var obj1 = document.getElementById("t1");
alert("obj1的类型是:" + obj1.nodeName);
var obj2 = document.getElementById("s1");
alert("obj2的类型是:" + obj2.nodeName);
}
</script>
<body>
Input Text:<input type="text" id="t1" name="t1"/><br/>
Select:
<select id="s1" name="s2">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
</body>
通过其他手段拿到一个控件(比如document.getElementById(...))后,可以用nodeName来获得控件的标签类型。下面是一个小例子:
<script>
window.οnlοad=function(){
var obj1 = document.getElementById("t1");
alert("obj1的类型是:" + obj1.nodeName);
var obj2 = document.getElementById("s1");
alert("obj2的类型是:" + obj2.nodeName);
}
</script>
<body>
Input Text:<input type="text" id="t1" name="t1"/><br/>
Select:
<select id="s1" name="s2">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
</body>
<script>
window.οnlοad=function(){
var obj1 = document.getElementById("t1");
alert("obj1的类型是:" + obj1.nodeName);
var obj2 = document.getElementById("s1");
alert("obj2的类型是:" + obj2.nodeName);
}
</script>
<body>
Input Text:<input type="text" id="t1" name="t1"/><br/>
Select:
<select id="s1" name="s2">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
</body>