I want to trigger a click event on a
<div id="showbanner">show banner</div>
The issue is because your
trigger('click'); call is the first thing in your script; it's called before the event is attached.
You need to move it to the end of the script so that the event handlers are bound when it is called: