codice:
$(function(){ // <- questo e' il tuo document.ready
    var hash=self.location.hash;
    var idToLookFor=hash.substr(1)||false;
    if(idToLookFor && $('#'+idToLookFor)){
        // <- qui fai quello che devi fare con $('#'+idToLookFor)
    }
})