Home Is there an "exists" function for jQuery?
Reply: 0

Is there an "exists" function for jQuery?

user4858
1#
user4858 Published in September 19, 2018, 6:44 pm

How can I check the existence of an element in jQuery?

The current code that I have is this:

if ($(selector).length > 0) {
    // Do something
}

Is there a more elegant way to approach this? Perhaps a plugin or a function?

share|improve this question

38 Answers 38

active oldest votes
1 2 next
up vote 2113 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.504634 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO