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


Please Help Members By Posting Answers For Below Questions

How to add and remove css classes to an element using jquery?

581


Which program is useful for testing jQuery?

635


How we can remove an attribute of an html tag in jquery?

580


Please explain remove class jquery with example?

623


Explain the difference between jquery's ready and holdready?

559


Explain chaining in jquery? : jquery mobile

626


What are the advantages of minified version of jquery?

589


Difference between javascript and jquery? : jQuery Mobile

613


Mac, windows or linux? Why do you love this platform while using jquery?

589


Explain is jquery replacement of java script? : jquery mobile

607


How you get server response from an ajax request using jquery?

606


Difference Between Prop and Attr in jQuery?

627


what is the use of param() method in jquery .

529


How to Use the jQuery load() Method?

685


How to programmatically trigger a click event that's being handled by jquery?

633