How do you check if an element exists or not in jQuery?
Answer / chaitanya
Using jQuery length property, we can ensure whether element exists or not.
Hide Copy Code
$(document).ready(function(){
if ($('#element').length > 0){
//Element exists
}
});
| Is This Answer Correct ? | 0 Yes | 0 No |
How to resolve conflicts with other libraries?
How can I select 20th div with jquery?
What is the use of toggle() method in jquery?
What is the difference between event.stopPropagation and event.stopImmediatePropagation?
How to multiple AJAX requests be run simultaneously in jQuery?
Can you please explain the difference between prop and attr? : jquery mobile
How to add a class to html element?
Explain the difference between .js and .min.js?
How to disable cut,copy and paste in TextBox using jQuery?
Is jQuery is a JavaScript or JSON library file?
How to include jquery library in asp.net project?
How do you add an HTML element in DOM tree?