* You can use the length property of the jQuery collection returned by your selector: should i take
if ( $(‘#myDiv’).length)
$(‘#myDiv’).show();
Note: It isn’t always necessary to test whether an element exists.The following code would show the item if it exists, and do nothing (no errors) if it did not:
$(‘#myDiv’).show();

Comments