3
我使用此代碼顯示彈出式窗口在懸停在一個站點區域的jQuery:冷凝,而不是寫代碼,每個彈出
HTML
<map id='_Image-Maps_1201306032036494' name='Image-Maps_1201306032036494'>
<area shape='rect' coords='35,352,64,380' rel='one1'/>
</map>
<div id='one1' class='popBox'><div class='inside'><h4>Newspapers and mail piling up</h4><p><strong>Tip:</strong> When you go on vacation, call your local post office and newspaper provider to put your mail and newspaper delivery on hold. Or ask a reliable neighbor to pick it up for you.</p></div></div>
jQuery的
$('area[rel="one1"]').hover(
function(){
$('#one1').show();
},function(){
$('#one1').hide();
});
不過我有相當多的領域,我需要這個工作。區域rel始終與需要彈出的div上的ID相同。不用爲每個單獨的彈出窗口編寫代碼,是否有辦法設置它,所以無論何時將鼠標懸停在圖像地圖上的某個區域上,它都會顯示與該區域相同的rel的彈出窗口?
簡單起見,我建議:'$( '區[相對]')懸停(函數(){ $( '#' + this.rel).toggle(); });'* *已測試。** –
完美,謝謝! –
哦,你很受歡迎;我很高興得到了幫助! =) –