On May 8, 3:15 pm, "Jonathan Sharp" <[EMAIL PROTECTED]> wrote:
> On 5/8/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> > I've got a slightly ugly bit of code where I check to see if the user
> > has specified an existing element by ID for the container. I'd
> > appreciate suggestions for cleaning this up:
>
> Why not do:
> var container = ($(options.container).parent().size() == 1) ?
> $(options.container) :
> $(options.container).insertAfter(this).addClass(options.classname);
>
> You're not limited to just the id selector then.
>
> -js
>
That was my initial thought, but I couldn't get it to work.
Strangely enough, $("<em>").parent().size() returns 1 when I wouldn't
expect it to. For some reason, $("<em>").parent() returns [div]. I
can't figure out why this is.
If I do $("<em>").parent().parent().size(), it returns 0.