I have to use external/named functions for hover, like this:
function onMouseIn(e){
// Do stuff
}
function onMouseOut(e){
// Do stuff
}
for (var btn_index = 0; btn_index < 3; btn_index++) {
btn.hover(onMouseIn,onMouseOut)
}
However i also need to pass arguments to the functions, so i figured out i'd use unnamed functions for mouseIn and mouseOut events and call my named functions onMouseIn and onMouseOut repectively with the arguments i want. I also want to pass the event and the jquery object. So my code becomes something like this
function onMouseIn(e,btn){
// Do stuff using arg
}
function onMouseOut(e,btn){
// Do stuff using arg
}
for (var btn_index = 0; btn_index < 3; btn_index++) {
btn.hover(
function(e) {onMouseIn(e,$(this))},
function(e) {onMouseOut(e,$(this))})
}
But then jshint give me this warning
Don't make functions within a loop.
So are there any other ways to pass arguments to named functions? If not then how can i make jshint to hide the warning?