It turns out that $() always return a object, which has a .length can be used to see if something has found.
So, I can do something like:
if ($('something').length > 0) {
alert('The DOM element has found!');
}
There is one more way to archive the same:
if ($('something').is('*') != '') {
alert('The DOM element has found!');
}
Comments
Leave comment
Trackback