<input type="text" id="tb_Test" />
<input type="button" id="btn_Test" value="Button />var type = document.getElementById("tb_Test").type;
if(type == "text"){
 alert("it is input box.");
}
if(type == "button"){
 alert("it is button.");
}

解决方案 »

  1.   

    <input type="text" id="txt">
    <select id="select"><option>1</option></select>
    <script type="text/javascript">
    var txt=document.getElementById("txt");
    var select=document.getElementById("select");
    alert(txt.type);
    alert(select.type);得到结果你自己看看就知道了
      

  2.   


    <input id="tt"/>
    <select id="select1" onchange="chengSelect()"> 
      <option value="1">test </option> 
      <option value="2">test1 </option> 
      <option value="3">test2 </option> 
    </select> 
    <script>  
    var input = document.getElementById("tt");
    var select1 = document.getElementById("select1");
    alert(input.tagName);
    alert(select1.tagName);  
    </script>  
      

  3.   

    alert(obj.tagName);if(obj.tagName=="INPUT"){
        alert(obj.type);
    }