$('#thebutton').mousedown(function(event) {
  alert('click')
})

setTimeout(function(){ 
    console.log('trying mouse down')
    $('thebutton').mousedown()
    $('thebutton').trigger('mousedown')
  
  	var e1 = document.createEvent("MouseEvents");
	e1.initMouseEvent("mousedown", true, true, window, 1, 0, 0, 0, 0, false, 	false, false, false, 0, null);
	$('#thebutton')[0].dispatchEvent(e1)
}, 3000);

Why does lines and 7 and 8 not work, but lines 10-12 do?… mystery for now, but hopefully the code block above helps you get past the issue.