The jQuery object $("#myid") always returns something - a jQuery object. To check if it actually represents an excisting DOM element on the page you can use the following:
if ( $("#myid").length > 0 ) { //do something }
I had some issue using .length attribute, but I can't remember which one !