Skip to content

Instantly share code, notes, and snippets.

@ayozebarrera
Created September 18, 2014 15:33
Show Gist options
  • Save ayozebarrera/ce99a7eb190a46e764f3 to your computer and use it in GitHub Desktop.
Save ayozebarrera/ce99a7eb190a46e764f3 to your computer and use it in GitHub Desktop.
Ignore an element inside an element
$.fn.ignore = function(sel){
return this.clone().find(sel).remove().end();
};
//<div id="test"><b>Hello</b>!!!<span>w00t!!</span>
//var text = $('#test').ignore("span").text(); "Hello!!!"
//var html = $('#test').ignore("span").html(); "<b>Hello</b>!!!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment