[jQuery] Re: appendingTo a just created element

2009-01-31 Thread Ricardo Tomasi
Using the DOM insertions method is the correct way to insert content into a page. If you need better performance, concatenate everything in a string and append it all at once, that can make a big difference. On Jan 31, 7:41 pm, Nicky wrote: > Hi All, > > Thanks for the great responses, jsbin is

[jQuery] Re: appendingTo a just created element

2009-01-31 Thread Nicky
Sorry, to be more specific by 'code' I mean HTML. :) -Nicky On Jan 31, 4:41 pm, Nicky wrote: > Hi All, > > Thanks for the great responses, jsbin is great. I've figured out the > problem and things seem to be working smoothly at the moment. > > If I may, let me ask another related question: > >

[jQuery] Re: appendingTo a just created element

2009-01-31 Thread Nicky
Hi All, Thanks for the great responses, jsbin is great. I've figured out the problem and things seem to be working smoothly at the moment. If I may, let me ask another related question: Ultimately, this script is writing a web widget to a page. Is there an easier way to be writing large amounts

[jQuery] Re: appendingTo a just created element

2009-01-31 Thread Stephan Veigl
Hi Nicky, where do the variables elm, and serial come from? Your posted code snipped looks ok, and it's working fine if you populate the elm and serial with meaningful values. (see example: http://jsbin.com/oxehe/edit) I guess there is a problem with elm. Are you sure it holds exactly 1 DOM ele

[jQuery] Re: appendingTo a just created element

2009-01-31 Thread Ricardo Tomasi
Do you use Firebug? First check if the element has been really inserted to the DOM. $('') .attr('id', 'someID') .insertBefore(elm); alert( $('#someID').length ); // console.info( $('#someID').length ); I'm sure if you post a full test case at jsbin.com or somewhere else on-line your p

[jQuery] Re: appendingTo a just created element

2009-01-31 Thread Nicky
Ah, very sorry about that mistype, but that is in fact what I am doing (just replaced my code wrong when I changed what I have to 'someID') Here's what I have, exactly: $('') .attr('id', 'ntww-'+serial) .insertBefore(elm); $('') .ap

[jQuery] Re: appendingTo a just created element

2009-01-31 Thread Stephan Veigl
the selector for an id is #, sou you should use "#someID" instead of "someID" for the appendTo() function. by(e) Stephan 2009/1/31 Nicky : > > Hi All, > > I'm fairly new to jQuery so I apologize if I'm missing something > straightforward but doing this: > > $('') >.attr('id', 'someID')