vendredi 5 janvier 2018

Using jQuery find() inside and if conditional

Why does this code alert “found it” and not “nope”?

HTML

<div class="site-inner">
  <div>Another div</div>
</div>
<footer class="vc_row">Footer</footer>

jQuery

if ( $('.site-inner').find('.vc_row') ) {
    alert('found it');
} else {
    alert('nope');
}

Aucun commentaire:

Enregistrer un commentaire