[jQuery] stripping out tags...

[jQuery] stripping out tags...


>
> <div id="someId">
> <label for="someFor">some <span>text</span> here</label> </div>
>
> I want to remove the <label> tag and preserve what it contains.
> But while I was writing my question, I came up with this:
>
> jQuery.fn.stripOut = function (el) {
> $(this).each( function(){
> $(this).find(el).parent().html(($(this).find(el).html()));
> })
> }
How about an .unwrap method to do the opposite of .wrap?
jQuery.fn.unwrap = function (el) {
return this.each( function(){
$(this.childNodes).appendTo(this.parentNode);
});
};
$('label').unwrap().remove();
I guess it's really more like .dumpChildrenOnGrandparent, but .unwrap is
shorter. :)
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/