How do you check if an element exists or not in jQuery?
Answer Posted / 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 |
Post New Answer View All Answers
What is the difference between prop() and attr() in jquery?
How can events be prevented to work after an ajax request?
Can you write a code to select all links inside the paragraph?
What is difference between sorting string array and sorting numerical array in jquery?
Create a plugin that would add and remove a class on hover.
How we can check if an element is empty or not using jquery?
How to run an event handler only once in jQuery?
Whether we need to add jQuery file in both Master and Content page?
What is the use of jQuery filter?
How to stop jqm from auto-enhancing an element? : jquery mobile
What is the use of jquery.data()?
Define type paremeter of jquery ajax method?
What is cdn and how jquery is related to it?
What is jquery.size()? : jquery mobile
Explain deferred and promise object in jquery? : jquery mobile