jquery Checking to see if element has element

Posted by Mark on Stack Overflow See other posts from Stack Overflow or by Mark
Published on 2010-05-11T02:53:21Z Indexed on 2010/05/11 3:04 UTC
Read the original article Hit count: 177

Filed under:

I'm using jquery 1.3 and is trying to duplicate the 1.4 .has functionality.

I need to check if the .page element contains the image, and if it doesn't, append it.

Is it something like:

var imageid = thirdimage;

if ($('#page:has(#'+imageid+')') === undefined) {
   $('#page').append($('#'+imageid));
}

Thanks.

© Stack Overflow or respective owner

Related posts about jQuery