@nsrosenqvist/jquery.exists

Simple jQuery plugin to test whether an element exists

Usage no npm install needed!

<script type="module">
  import nsrosenqvistJqueryExists from 'https://cdn.skypack.dev/@nsrosenqvist/jquery.exists';
</script>

README

jQuery Exists

A jQuery plugin to check whether an element exists and if so run the callback on the element.

Installation

npm install @nsrosenqvist/jquery.exists

Usage

$('.maybe-exists').exists(function() {
    $(this).addClass('definitely-exists');
});

if ($('.maybe-exists').exists()) {
    alert('exists');
}

License

MIT