简体   繁体   中英

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 . Since it gets the href off the element and adds that class , it's not <a> dependent, you can just do:

<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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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