MCQs > IT & Programming > JQuery > Correct way to check the existence of an element in jQuery other than the following code? if ($(selector).length>0) { // Do something }

JQuery MCQs

Which of the following is the correct way to check the existence of an element in jQuery other than the following code? if ($(selector).length>0) { // Do something }

Answer

Correct Answer: jQuery.fn.exists = function(){return this.length>0;} if ($(selector).exists()) { // Do something }

Explanation:

Note: This Question is unanswered, help us to find answer for this one

JQuery Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

JQuery Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it