innerText 试过, 没用。

解决方案 »

  1.   

    <P>标记不能这么写的,你这种写法在浏览器里面的呈现是
    <p id="test">前面</p><div><div>测试</div></div><p></p>
    所以用 innerHTML 取不到,换其它的吧
      

  2.   

    innerHTML应该是没问题吧。
    是不是你其他地方的问题?
      

  3.   

    <p id="test">前面</p><div><div>测试</div></div><p></p>
    该成
    <p id="test">前面<div><div>测试</div></div></p>
      

  4.   

    <P style="color: #000; font-size: 14px" id="c_55">
         I Support Your Perspective<div class=textDiv><div class=contentDiv>这还是我说的</div></div>
       </P>
    上面这个是我从源码里面取出来的,这里好像没有4楼说的那样。
      

  5.   

    这个不是js的问题.
    dhtml手册里对于p标记,提供的有childnode的属性及相关集合.
    但经测试发现问题,p 标记无法含子标签.用canHaveHTML属性得到true,即p元素可以含子html元素,但事实发现,是假的.<script>
    function answer(arg) {
    arg ? alert("Yes") : alert("No");
    }
    </script>
    <p id="test">前面<div id="d1"><div id="d2">测试</div></div></p>
    <script>
    answer(document.getElementById("test").canHaveHTML);//true
    alert(document.getElementById("test").outerHTML);//<p id="test">前面
    alert(document.getElementById("test").childNodes.length);//1 ,有一个子元素,是否为d1呢
    alert(document.getElementById("test").childNodes[0].childNodes.length);//1 ,如果上面指的是d1,那么这里应该也得到1,即d1有一个子元素d2,但这里得到0
    //那么 test.childNodes[0],即 p id="test"的子元素指的是哪个呢
    alert(document.getElementById("test").childNodes[0].id);//undefined  很明显不是d1,也不是d2,否则 不会是undefined
    alert(document.getElementById("test").childNodes[0].tagName);//undefined 更加确定不是d1,也不是d2. 否则会弹出 "DIV"
    //接着就怀疑,test的这个childnode指的就是这两个字"前面"
    //将前面二字删除,继续alert test.childnodes.length已经是0了。 真相大白了

    </script>除了用脚本调用idocument接口测试外,我们再看html呈现<p>asdfasdfasdf</p>
    <p style="line-height: 350%">asdfasdfasdf<br/><div>asdfasdfasdf<br/>asdfasdf</div></p>
    <p>asdfasdfasdf</p>
    <p> </p>第二个p标记设了行距350%, 如果里面没有含div, 那么按照br换行后,这三行都有350%的行距, 加上div, div内的行距无效,即说明, div不能成为p的子标签.也即得出结论, p是支持含html元素(比如br)为子的,但不支持div做为子标签,至于哪些支持,哪些不支持,只有自己测试了.
      

  6.   

    好了,问题解决,  因为P不是HTML元素, 用INNERHTML这样的方法取不到《P》候面的值。
      

  7.   

    P不是html元素? 呵呵,这句说话的... 我都不知道说什么好了.