<input type="button" id="button1" value="test">
<script>
alert(document.getElementById("button1")==null?"button1不存在":"button1存在")
</script>
可以修改id="其它名字"看看

解决方案 »

  1.   

    var e = window.document.getElementById("BUTTON1") 
     if (e != null) 
     {
    alert ("存在")
     }
     else
     {
    alert ("不存在")
     }
      

  2.   

    if(document.getElementsByName("BUTTON1").length > 0)
     ....
      

  3.   

    <input id=button1>
    <input id=button1>
    <input id=button2><script>
    function check(str){
    alert(str+":"+(document.all(str)!=null?"存在":"不存在"))
    }
    check("button1")
    check("button2")
    check("button3")
    </script>
      

  4.   

    <input id=button1>
    <input id=button1>
    <input id=button2>
    <script>
    function check(str){
    alert(str+(document.all(str)==null?"不":"")+"存在")
    }
    check("button1")
    check("button2")
    check("button3")
    </script>