Jquery Checking for an element with an element

I am using jquery 1.3 and trying to duplicate 1.4.has functionality.

I need to check if the .page element contains an image, and if not, add it.

This is something like:

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

Thanks.

+7
jquery
source share
2 answers
 if( $('#page').find('#'+imageid).length ) // I has the image! :P 
+17
source share
 $('#page').find('#'+imageid).length == 0 
+4
source share

All Articles