I have something like that:
<div onclick="doSomething('foo', 'bar');"></div>
As you can see, the event isn't passed to the handler. Is it somehow possible to access it inside the handler anyway?
I have something like that:
<div onclick="doSomething('foo', 'bar');"></div>
As you can see, the event isn't passed to the handler. Is it somehow possible to access it inside the handler anyway?
As you can see, the event isn't passed to the handler. Is it somehow possible to access it inside the handler anyway?
No.
The best way to accomplish this is to add an id to your div, and set up the event handling from a script.
This should do what you're looking for
<div id='myDiv'></div>
And then
function doSomething(evt, str1, str2) { ... }
document.getElementById('myDiv').onclick = function(e) {
doSomething(e, 'foo', 'bar');
};
Just make sure the script tags that contain the above are at the bottom of you body tag, so the script doesn't run until the dom is created and ready.