Answers for "how to know that an element exists using jQuery"

4

jquery test div exists

$(document).ready(function() {
    var $myDiv = $('#DivID');

    if ( $myDiv.length){
        //you can now reuse  $myDiv here, without having to select it again.
    }


});
Posted by: Guest on March-27-2020
-1

jQuery exists function

if ($("#myElementID").length){
   //I exist
}
Posted by: Guest on July-22-2019

Code answers related to "how to know that an element exists using jQuery"

Code answers related to "Javascript"

Browse Popular Code Answers by Language