[jQuery] $.WRAP is good, yet how about $.UNWRAP function? tips?
hey peeps, wonder what you all use or could use, to UNWAP a tag, after its been its been added with teh $.wrap() function for example: text etc.. so lets say you wanted to just keep the P tag, and unwarp the it, (drop span tag)? would be nice to just to do something like... $('removeMe').unwarp(); in turn would result in .. text etc... what to drop only the span tag without too much effort., any quick or easy already exciting function that do this? thanks, -- Nilesh B. Patel define-web.com ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] $.WRAP is good, yet how about $.UNWRAP function? tips?
My stab at it: $.fn.unwrap = function(expr) { return this.each(function(){ $(this).parents(expr).eq(0).after(this).remove(); }); }; Then you could do: $("#keepMe").unwrap("span"); Untested, but worth a shot. --John > wonder what you all use or could use, to UNWAP a tag, > after its been its been added with teh $.wrap() function > > for example: > text etc.. > > so lets say you wanted to just keep the P tag, and unwarp the it, (drop > span tag)? would be nice to just to do something like... > $('removeMe').unwarp(); > in turn would result in .. text etc... > > what to drop only the span tag without too much effort., any quick or > easy already exciting function that do this? > thanks, ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/