这里改一下: window.alert( thisObject.innerText);

解决方案 »

  1.   

    <div name="myObject" id=="myObject" style="position: absolute; left: 241; top: 15; width: 150; lineheight: 8px; ">This is my object with.</div>
    少了ID
    你是通过ID拿对象的,所以必须要有ID
      

  2.   

    但是 lineheight 还是没有发生变化,如果这样写是有变化的:<div name="myObject" onmouseover="this.style.lineHeight='200px'"
            style="position: absolute; left: 241; top: 15; width: 150; lineheight: 8px; ">This is my object with.</div>
      

  3.   

    你的属性使用错误:要区分大小写的
    <script language="JavaScript">
    function moreSpace(objectID) 
    {
    var thisObject = document.getElementById( objectID );
    thisObject.style.lineHeight =  "3";
    }
    </script><div id="myObject" name="myObject" style="position: absolute; left: 241; top: 15; width: 150; lineheight:20px;">This is my object with.This is my object with.This is my object with.</div>
    <a href="#" onClick=moreSpace("myObject") >Increase the line spacing.</a>
    不过初始的那个style中的设置还是没有起作用,不知道为什么。
    点击事件中的是可以了
      

  4.   

    但是这样还是有错,除非你先激发 onmouseover="this.style.lineHeight='200px'" 事件,然后moreSpace 函数才会执行,不然会报错:
    -----------------------------------------------------------------------------------<html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>New Page 1</title>
    <script language="JavaScript">
    function moreSpace(objectID) 
    {
    var thisObject = document.getElementById( objectID );
    window.alert( thisObject.innerText);
    thisObject.style.lineHeight = parseInt(thisObject.style.lineHeight ) + 10 + "px";
    window.alert( thisObject.style.lineHeight );
    }
    </script>
    </head><body>
    <div name="myObject" id="myObject" onmouseover="this.style.lineHeight='200px'"
    style="position: absolute; left: 241; top: 15; width: 150; font-size: 14px; lineheight: 10px; background-color: #cccccc; height: 52">
    This is my object with.
    </div>
    <br>
    <a href="JavaScript:moreSpace('myObject');">moreSpace</a>
    <a href="#" onClick=moreSpace("myObject") >moreSpace</a>     </body></html>
      

  5.   

    测试通过。
    -------------------------------------------
    <script language="JavaScript">
    function moreSpace(objectID) 
    {
    var thisObject = document.getElementById( objectID );
    alert( thisObject.innerText);
    thisObject.style.lineHeight =  250 + "px";
    }
    </script> <div id="myObject" style="position: absolute; left: 241; top: 15; width: 150; lineheight: 8px; ">This is my object with.</div>
    <a href="#" onClick=moreSpace("myObject") >Increase the line spacing.</a> 
      

  6.   

    测试通过。
    -------------------------------------------
    <script language="JavaScript">
    function moreSpace(objectID) 
    {
    var thisObject = document.getElementById( objectID );
    alert( thisObject.innerText);
    thisObject.style.lineHeight =  250 + "px";
    }
    </script> <div id="myObject" style="position: absolute; left: 241; top: 15; width: 150; lineheight: 8px; ">This is my object with.</div>
    <a href="#" onClick=moreSpace("myObject") >Increase the line spacing.</a> 
      

  7.   

    不用再找了,错误的原因在于你的样式写错了
    lineheight: 8px
    =>
    line-height:8px
    其它没问题
      

  8.   

    wxylvmnn(城隍庙三当家的)
    -- 你的代码和我的没有什么分别啊?ice_berg16(寻梦的稻草人) 
    -- 即便我改写成 line-height:8px 但是第一次仍然无法改变 line-height; 只有第二次才成功
      

  9.   

    wxylvmnn(城隍庙三当家的)
    -- 你的代码和我的没有什么分别啊?ice_berg16(寻梦的稻草人) 
    -- 即便我改写成 line-height:8px 但是第一次仍然无法改变 line-height; 只有第二次才成功
      

  10.   

    看看这个代码吧,如果再说和你的没分别拜托请先完整的对比一下再发言。<script language="JavaScript">
    function moreSpace(objectID) 
    {
    var thisObject = document.getElementById( objectID );
    //alert(thisObject);
    thisObject.style.lineHeight=  40 + "px";
    }
    </script> <div id="myObject" style="position:absolute;left:241px;top:15px;width:150px;line-height:10px;">This is my object with.</div>
    <a href="#" onClick='moreSpace("myObject")' >Increase the line spacing.</a>
      

  11.   

    ice_berg16(寻梦的稻草人) ( ) 谢谢,先测试一下:
      

  12.   

    wxylvmnn(城隍庙三当家的)
    -- 你的代码和我的没有什么分别啊?
    ---------------------------------------你確定你是一個一個字母對了麽!!!!