0

HTMLタグでテキストを取得する方法はありますが、メインDIVからのみですか? 他の DIVS を形成しない。

以下に例を示しますが、テキストに html タグが含まれていないため、問題があります < br />

jsFiddle デモ

HTML

<div id='parent'>
    this text is <br />for parent

   <div id='child-parent'> 
     this text if for child-parent  
       <div id='child'>
        and this text is for child.   
       </div>   
   </div>
</div>

jQuery

alert($('#parent').clone().children().remove().end().html());
4

2 に答える 2