Would this work? It would preserve node order.

jQuery.fn.unwrap = function () {
   return this.each( function(){
      $(this.childNodes).insertBefore(this);
   });
};

Blair

On 11/7/06, Dave Methvin <[EMAIL PROTECTED]> wrote:

>
> <div id="someId">
>    <label for="" <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
[email protected]
http://jquery.com/discuss/

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to