How do you check if an element exists or not in jQuery?



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

Post New Answer

More jQuery Interview Questions

How do I pull a native DOM element from a jQuery object?

0 Answers   MCN Solutions,


Explain the difference between .js and .min.js?

0 Answers  


Is jquery is json library file or a javascript?

0 Answers  


Which one is more efficient, document.getElementbyId( "myId") or $("#myId)?

0 Answers  


How to check if number is numeric while using jQuery 1.7+?

1 Answers  


When can you use jquery?

0 Answers  


How JavaScript and jQuery are different?

1 Answers  


What is jquery a client or server scripting?

0 Answers  


What is the use of queue() in jquery?

0 Answers  


Explain slidetoggle() effect.

0 Answers  


Do you have plans for a new jquery plug-in or something else we should look out for? Where to from here for the imgpreview plugin?

0 Answers  


What is the purpose of jquery?

0 Answers  


Categories