Possible Duplicate:
Why does $(‘#id’) return true if id doesn’t exist?
I have a very simple js function:
function refresh(ltr) {
if (board.find('p:contains("' + ltr + '")')) {
board.find('p:contains("' + ltr + '")').show();
} else {
alert('Hello.');
}
}
Obviously I pass a string to ltr, it works fine if it contains the string but if not it do not fire the alert…
Do you know why?
Because
.findreturns a jQuery object which always evaluates totrueTry a boolean expression: