Results 1 to 4 of 4
Mar 14, 2012, 12:23 #1
- Join Date
- Jul 2011
- 0 Post(s)
- 0 Thread(s)
someElement.onclick = someFunction: how to pass an argument to function?
I have this bit of code that is working just fine:
someElement.onclick = someFunction;
var theid = this.getAttribute('id');
So far so good but...
I would like to be able to use someFunction not only as the result of an onclick event. For example, I'd like to use it like that:
someElement.onclick = someFunction(this.getAttribute('id'));
I would like to know how I can pass an argument to someFunction when it is the result of my onlick event so I can also use someFunction() without having to clone it (and change its name slightly) just so it can receive an argument.
I hope my problem is clear so I can get an answer...