Last active
January 2, 2016 10:58
-
-
Save wangwen1220/8293098 to your computer and use it in GitHub Desktop.
JS: jQuery 处理所有节点文本 | element contents each
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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