Another question I have is why am i unable to assign an event handler to a variable and work with it. Instead of doing this
- var eventTarget = $("#evtTarget");
- $(function() { $("#evtTarget").on("mouseover mouseleave", highlighted); });
- function highlighted () { $("#evtTarget") .toggleClass("highlighted"); }
Id rather assign eventTarget and use that variable as a handler. But for some reason its not working??
- var eventTarget = $("#evtTarget")
- $(function() { eventTarget.on("mouseover mouseleave", highlighted); });
- function highlighted () { eventTarget.toggleClass("highlighted"); }