Christian Bach just posted his .wrapInner() plugin to the discussion
list about a week ago:
Here is the new version.
jQuery.fn.wrapInner = function(o) {
return this.each(function(){
var jQ = jQuery(this);
var c = jQ.html();
jQ.empty().append(o.el).filter(o.id).html(c);
});
}
$("p").wrapInner({el: '<a href="http://jquery.com">', id: 'a'});
Before:
<p>I will become a link to jQuery.com</p>
After:
<p><a href="http://jquery.com">I will become a link to jQuery.com</
a></p>
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Feb 27, 2007, at 3:39 PM, Daniel MacDonald wrote:
Is there a jQuery way to do an innerWrap? For example:
<div class="outerdiv">
<h3>blah blah blah</h3>
<p>Lorem ipsum dolor sit amet<p>
</div>
I am looking to wrap all of the contents of .outerdiv with another
div as
in:
<div class="outerdiv">
<div class="innerdiv">
<h3>blah blah blah</h3>
<p>Lorem ipsum dolor sit amet<p>
</div>
</div>
I tried using .prepend('<div class="innerdiv">') and .append('</
div>'), but
the prepend operation closes the div tag. I tried cloning the
children of
.outerdiv, emptying .outerdiv, appending the .innerdiv, and
appending the
cloned children, which works, but not with multiple classes. Any
suggestions?
--
View this message in context: http://www.nabble.com/Is-there-a-
jQuery-way-to-do-an-innerWrap--tf3304247.html#a9191323
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/