Hi, this is probably quite a basic one, but I'm struggling to get an argument passed in to a function successfully.
When I do this, the code doesn't execute:
document.onclick = newTarg(5);
document.ondblclick = newTarg(10);
function newTarg(spd) {
alert('Working = '+spd);
// More code here
}
Doing this instead works fine:
document.onclick = newTarg;
function newTarg() {
alert('Working');
// More code here
}
Any ideas why it won't let me pass a variable in? I've never really formally learnt Javascript so this is getting a bit frustrating...