jquery if element exists code example
Example 1: CHECK IF element is hidden jquery
$(element).is(":visible");
$(element).is(":hidden");
Example 2: jquery check if element exists
if ($('#element').length) {
}
Example 3: jquery test div exists
$(document).ready(function() {
var $myDiv = $('#DivID');
if ( $myDiv.length){
}
});
Example 4: jquery check if attribute exists
var attr = $(this).attr('name');
if (typeof attr !== typeof undefined && attr !== false) {
}
Example 5: check element exist in jquery
if ($('.element').length) {
}
Example 6: jquery check if exist
if ( $( "#myDiv" ).length ) {
$( "#myDiv" ).show();
}