jquery if div exists code example
Example 1: jquery check if element exists
// Check if an element currently exists
if ($('#element').length) {
}
Example 2: 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.
}
});
Example 3: jquery check if exist
if ( $( "#myDiv" ).length ) {
$( "#myDiv" ).show();
}