Since you do not have a binding to the event .click(), it never fires.
You need to fire the DOM event clickusing jQuery .click()instead .trigger(e), and this should only work on dom nodes. This can be done by entering an index [0]or using the jQuery method .get(0).
Instead, try the following:
$(document).ready(function() {
$(".button2")[0].click();
});
and if so, you can only do this with javascript:
window.addEventListener('DOMContentLoaded', function(e){
document.querySelector('.button2').click();
}, false);
source
share