[jQuery] Re: multiline string

2007-08-03 Thread Karl Swedberg
Another way you could do this with multiple lines would be to  
use .insertAfter() . Something like this maybe:


$(')
.append('sample')
.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(
'' +
'sample' +
''
);

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([
'',
'sample',
''
].join(''));


--Klaus




[jQuery] Re: multiline string

2007-08-03 Thread james_027

hi,

nice trick!

cheers,
james


On Aug 3, 4:23 pm, Klaus Hartl <[EMAIL PROTECTED]> wrote:
> james_027 wrote:
> > hi,
>
> > I am trying to use the jQuery .after() function. I have something like
> > this ..
>
> > $('p').after('sample');
>
> > I want to transform it into something like this to make the code much
> > easier to read
>
> > $('p').after('
> > 
> > sample
> > 
> > ');
>
> > how can I achieve this?
>
> > Thanks
> > james
>
> The + operator does string concatenation in JavScript:
>
> $('p').after(
>  '' +
>  'sample' +
>  ''
> );
>
> 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([
>  '',
>  'sample',
>  ''
> ].join(''));
>
> --Klaus



[jQuery] Re: multiline string

2007-08-03 Thread Klaus Hartl


james_027 wrote:

hi,

I am trying to use the jQuery .after() function. I have something like
this ..

$('p').after('sample');

I want to transform it into something like this to make the code much
easier to read

$('p').after('

sample

');

how can I achieve this?

Thanks
james


The + operator does string concatenation in JavScript:

$('p').after(
'' +
'sample' +
''
);

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([
'',
'sample',
''
].join(''));


--Klaus