document.getElementById('mainbar').addEventListener("click", function() { console.log('main bar clicked'); }); Using jQuery: $('#buttonid').click();