如果我点击#parent
,我希望返回其中的文本,而不是返回嵌套层(#child-parent
,#child
)中的文本。
<div id='parent'>
this text is for parent
<div id='child-parent'>
this text if for child-parent
<div id='child'>
and this text is for child.
</div>
</div>
</div>
这个:
$('#parent').html() = "这段文本是给父元素的"
而不是这个:
$('#parent').html() = "这段文本是给父元素的,这段文本是给子元素-父元素的,这段文本是给子元素的"