Вопрос

I would need to pass the context to my calls to showPictureZoom (event over). Does anyone know how to do it? The idea is that I need to pass a variable (the image src) stored in the dom and I have no idea how I can do that...
Here is what I have so far:

var showPictureZoom = function(src)
{
    console.log(src)
}

var config = {
    over: function(){showPictureZoom(context)},
    sensitivity:6,
    interval:400,         
    out: hidePictureZoom,
};

$(".image img").hoverIntent(config);

Thanks for your help! (:

EDIT: Here is the html code:

<td class="image">
    <img src="img_url" data-large-square="DATA_NEEDED">
</td>

What I need is to get the variable "data-large-square" in the over callback.

Это было полезно?

Решение

you can pass the context to "this", that is the element:

var showPictureZoom = function(el)
{
    console.log($(el).attr('src'));
}

var config = {
    over: function(){showPictureZoom(this)},
    sensitivity:6,
    interval:400,         
    out: hidePictureZoom,
};

$(".image img").hoverIntent(config);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top