再声明一下,这段代码是用在<div>标签里的。

解决方案 »

  1.   

    document.getElementById(obj)
    这句话的意思是返回了一个对象吗?
      

  2.   

    Returns a reference to the first object with the specified value of the ID attribute.SyntaxoElement = document.getElementById(sIDValue)
    ParameterssIDValue Required. String that specifies the value of an ID attribute. Return ValueReturns the first object with the same ID attribute as the specified value.ResIf the ID value belongs to a collection, the getElementById method returns the first object in the collection.ExampleThis example uses the getElementById method to return the first occurrence of the ID attribute value, oDiv.<SCRIPT>
    function fnGetId(){
       // Returns the first DIV element in the collection.
       <!-- @ED mapovey 4/11/2000 :Is this comment in the correct format? -->
       var oVDiv=document.getElementById("oDiv");
    }
    </SCRIPT>
    <DIV ID="oDiv">Div #1</DIV>
    <DIV ID="oDiv">Div #2</DIV>
    <DIV ID="oDiv">Div #3</DIV>
    <INPUT TYPE="button" VALUE="Get Names" onclick="fnGetId()">
      

  3.   

    看看吧这是document.getElementById的用法