You are not using the power of jQuery. For example,
document.getElementById
is not needed, because the jQuery ID selector does it. As to your question: you don't use
clicked
anywhere in code, so what do your expect?
Try to follow the general pattern of jQuery code, use
$( document ).ready
:
http://learn.jquery.com/about-jquery/how-jquery-works/[
^].
You can add a handled of the click event to the button's element, but the real jQuery pattern is to add it all dynamically, for better isolation of JavaScript from HTML. Here is how:
http://api.jquery.com/click/[
^].
—SA