Thursday, 21 April 2011

How to check whether an element exists using jQuery

There might be different ways of doing this. One is using the length property of jQuery selector as shown in the below code snippet

if ($("#elementid").length > 0){
// element exists, do something here
}

No comments:

Post a Comment