2012-02-24 39 views
0

我目前使用放大鏡插件放大設置爲圖像映射的大型組織圖片。通常,當用戶點擊這個圖像地圖的一部分時,它們會被重定向,不幸的是,我找不到一種方法可以讓放大鏡響應用戶點擊圖像地圖上的鏈接。任何建議將不勝感激!jQuery放大鏡和點擊活動

謝謝!

回答

0

我並不熟悉那個特殊的插件,但是你不能簡單地附上你自己的click事件處理程序嗎?

鑑於這種標記(基於在the plugin's GitHub repo演示):

<div> 
    <a class="demo" href="path/to/some/url"> 
     <img src="path/to/image" width="191" height="240" /> 
    </a> 
    <img class="demo" src="path/to/image" width="191" height="240" /> 
</div> 

您可以附加一個單擊處理程序是這樣的:

$(function(){ 
    $('a.demo').on('click', function(e){ 
     // prevent the link from going anywhere (if that's what you want) 
     e.preventDefault(); 

     // do something else... 
     alert('The Loupe link was clicked!'); 
    }); 
}); 

編輯補充,如果你有工作圖像地圖,您可以簡單地將單擊事件處理程序附加到<area>元素,如下所示:

$('area').on('click', function(e){ 
    // stuff here 
}); 
0

這是老問題,但答案很簡單: -

只是附加一個事件監聽器類.loupe

$('.loupe').on('click', function (e) { 
    e.preventDefault(); 
    alert('The Loupe link was clicked!'); 
}); 
0

如果你想放大鏡去定位標記父原來的img標籤,然後嘗試這一點,如果這不起作用,向所有原始圖像添加一個類,並在img之前添加到選擇器。

$('.loupe').click(function(){ 
     $("img[src='"+$(this).find('img').attr('src')+"']").parent()[0].click(); 
});