Check the existence of an element by the following if condition.
if ($("#mydiv").length > 0) { // do something if mydiv exists }
Done =)
Reference: How to check whether an element exists using jQuery
Advertisements
Check the existence of an element by the following if condition.
if ($("#mydiv").length > 0) { // do something if mydiv exists }
Done =)
Reference: How to check whether an element exists using jQuery
I found a function for it- $(selector).exists()
LikeLike
really? i can’t find it in the jQuery API. is that from other libraries?
LikeLike