Adam K Dean

Use jQuery to see if an element exists

Published on 17 January 2014 at 10:28 by Adam

You can use jQuery to see if an element exists by checking if the length of the jQuery object is > zero.

var exists = $('.your-selector-here').length > 0;

Probably the shortest snippet so far.



This post was first published on 17 January 2014 at 10:28. It was filed under archive with tags javascript, jquery.