Skip to content

Instantly share code, notes, and snippets.

@wangwen1220
Last active January 2, 2016 10:58
Show Gist options
  • Save wangwen1220/8293098 to your computer and use it in GitHub Desktop.
Save wangwen1220/8293098 to your computer and use it in GitHub Desktop.
JS: jQuery 处理所有节点文本 | element contents each
// jQuery 处理所有节点文本
$('#elem').contents().each(function() {
if(this.nodeType === 3 && $.trim($(this).text())) {
$(this).wrap('');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment