Noob: Call a function that requires "this" as an a
How do I link an existing function to the onclick event of one or more page elements, and send the object of the element that was clicked to that function?
-
//With plain old intrusive javascript:
<div class='someClassName' id='Hello' onclick='myFunction(this)'></div>
//With jQuery:
$(document).ready
(
function()
{
$("div.someClassName").click(function()
{
myFunction($(this));
});
}
);
//The function being called:
function myFunction(e)
{
alert(e.id);
}
The jQuery code doesn't work. How can I do this?
Thanks!
Icee