Saturday, January 31, 2009

[jQuery] Re: appendingTo a just created element

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 <nhajal@gmail.com>:
>
> Hi All,
>
> I'm fairly new to jQuery so I apologize if I'm missing something
> straightforward but doing this:
>
> $('<div/>')
> .attr('id', 'someID')
> .insertBefore(elm);
> $('<p/>')
> .appendTo('someID');
>
> Seems to give me errors. If I change "appendTo('someID')" to a
> different element's ID, it works fine, so I get the feeling that it
> can't append to the just-created div. Is this not the case? What
> should I do to move forward?
>
> Thanks for the help!
>

No comments: