Reputation: 5616
Say I have setup a basic div like this :
<div id='signatureBox'></div>
I then want to register whenever the box is clicked on / touched in any area. I am trying without success :
//Register signature callback
var signature = document.getElementById("signatureBox");
signature.onclick() = function () {
alert('signature JavaScript triggered');
}
Can anyone help ?
Thanks !
Upvotes: 0
Views: 1672
Reputation: 8954
You've put in the parentheses which are unneeded for the onclick in javascript. Correct working code is here
var signature = document.getElementById("signatureBox");
signature.onclick = function () {
alert('signature JavaScript triggered');
}
Working fiddle here http://jsfiddle.net/7m9EK/1/
Difference between HTML and javascript onclick
to be found here: http://www.w3schools.com/jsref/event_onclick.asp
Upvotes: 3