Another way you could do this with multiple lines would be to use .insertAfter() . Something like this maybe:

$('<p class="main"></p>)
        .append('<a href="#">sample</a>')
        .insertAfter('p');


--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com



On Aug 3, 2007, at 4:23 AM, Klaus Hartl wrote:

The + operator does string concatenation in JavScript:

$('p').after(
    '<p class="main">' +
        '<a href="#">sample</a>' +
    '</p>'
);

Turned out that this is a little slow thus I tend to use a array.join() if the string gets longer, which is known to be faster:

$('p').after([
    '<p class="main">',
        '<a href="#">sample</a>',
    '</p>'
].join(''));


--Klaus

Reply via email to