$('.clickedElement').live('click',function(){ //does the green check mark exist? if so then do nothing, else if($("#listItem span.greenCheckMark").length != 0) { $('#listItem').append('<span class="greenCheckMark"></span>'); } });
Well, after a few changes, this should be what you are looking for.
$("#listItem span.greenCheckMark").length != 0 will return an array of JQuery objects, if this area has a length not equal to 0, then it exists. Make sure that you specifically check where you want to check ( $("span.greenCheckMark").length will check the entire document for green checkmarks).
Alex larzelere
source share