3 ways to use Exists function for jQuery

jQuery is really useful for client website programming. It help us a lot but sometimes we need to spend time for very simple problem. This article will show you 3 ways to use exists function for jQuery what help you check if an element exists or not.

Simple check with length properties

To check exist element or not, just do a simple properties like this

You don’t need that >0 part.

Define exist function

To define a function then we can reuse easily in many projects, let’s use this function define for jQuery

Or simpler like this

Use exist in jQuery plugin

A better way is define it as a plugin for jQuery like this

After adding to your project you can use like this

Now, enjoy and welcome any comment :).

Leave a Reply

Your email address will not be published. Required fields are marked *

*