if (document.getElementById("xxx") ) {azione}

con jquery come si fa?