0

如何使用 DOMNodeInserted 从新插入的元素中获取文本。

例子:

<div id='elementID'>
    <span class='elementClass'>Some text</span> <!-- already present -->
    <span class='elementClass'>Some text</span> <!-- already present -->
    <span class='elementClass'>Some text</span> <!-- newly inserted -->
    ...
</div>
4

1 回答 1

0

您可以通过 event.target 获取它

$('#elementID').on('DOMNodeInserted', function(e) {
    console.log($(e.target).text());
});​

http://jsfiddle.net/Pccwc/

于 2012-12-18T22:26:38.250 回答