I have a thumbnail scroller where I want to trigger some action only when the mouse is hovered for 3 seconds on thumbnails. I have the following code but the inner setTimeOut function is not getting the arguments from the outer function--the sourceURL console output gets 'undefined' error. But the 'hover' function I do see correct sourceURL value.
Thanks in advance!
var tOut;
$('img.thumb').hover(function(){
var sourceURL = $(this).attr('src');
var lat = $(this).attr('lat');
var lng = $(this).attr('lng');
tOut = setTimeout(function(sourceURL,lat,lng){
console.log(sourceURL);//undefined
map.setView(new L.LatLng(lat, lng), (init_mapzoom+2));
},3000);
},function(){
clearTimeout(tOut);
});