Let's say I have the following situation:
<a href="#" id="trigger">CLICK ME</a>
and
var x = alert("test");
$('#trigger').click(function() {
x
});
Why is x
firing on loading the page, and not while pressing the button? I know when placing the variable into the function it works, but I don't really get why!