简体   繁体   English

带有HTML imagemap的jQuery

[英]JQuery with HTML imagemap

I can do something like this: 我可以做这样的事情:

$(document).ready(function(){
    $(".schedule_link").colorbox({width:"95%", innerHeight:344, iframe:true});
});

to attach the colorbox to a link ... 将颜色框附加到链接...

<a class='schedule_link' href="index.html">Schedules</a>

... but what is the syntax to attach it to an imagemap like this? ...但是将其附加到这样的图像映射的语法是什么?

<map name="mymap">
   <area shape="rect" coords="496,500,729,523" href="??call JQuery??">
</map>

您可以像链接一样为您的<area>标签提供一个类:

<area class="something" shape="rect" coords="496,500,729,523" href="somepage.html">

Colorbox actually operates on a .live() handler that listens for clicks on elements with the cboxElement class . Colorbox实际上在.live()处理函数上运行,该处理函数侦听cboxElement对元素的cboxElement Since it gets the href off the element and adds that class , it's not <a> dependent, you can just do: 由于它取消了元素的href添加了该类 ,因此它不是<a>依赖的,您可以执行以下操作:

<map name="mymap" id="mymap">
   <area shape="rect" coords="496,500,729,523" href="myPage.html">
</map>

And your jQuery to bind these in one go, no need on a class for each <area> , for example: 而且您的jQuery可以一次性绑定这些,而无需为每个<area>都使用一个类,例如:

$(function(){
  $("#mymap area").colorbox({width:"95%", innerHeight:344, iframe:true});
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM