7

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.

2
  • the has() selector has been available since 1.1.4 according to the doc. And I've used it specifically in 1.3.2. Are you sure this isn't some other issue? Maybe try $('#page').find('#'+imageid) === undefined Commented May 11, 2010 at 3:01
  • There's a new .has() method in 1.4 Commented May 11, 2010 at 19:25

2 Answers 2

17
if( $('#page').find('#'+imageid).length ) // I has the image! :P 
Sign up to request clarification or add additional context in comments.

Comments

4
$('#page').find('#'+imageid).length == 0 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.