Reputation: 13299
When I try to send "this"(element fired) as parameter to the function, the function received "Object[Document build.php]" as arguments instead of the element fired. Please let me know my fault:
function set(arg) {
var element = arg.data.param;
console.log(element);
}
$(".build_icon_container").on("mouseenter", {param: $(this)}, set);
Upvotes: 1
Views: 85
Reputation: 817238
At the moment you are trying to execute $(this)
, this
doesn't refer to the element(s) you are binding the event handler to.
It's much simpler:
this
inside the event handler will already refer to the correct element:
function set(event) {
console.log(this);
}
$(".build_icon_container").on("mouseenter", set);
jQuery has a nice set of tutorials regarding event handling: http://learn.jquery.com/events/event-basics/.
Upvotes: 4