可点击的美国地图绑定到多选列表框 -jQuery 点击事件未触发

Clickable USA Map bound to Multi select ListBox -jQuery click event not firing

本文关键字:-jQuery 事件 列表 美国 地图 绑定      更新时间:2023-09-26
<html>
<head><title>Image Map</title>
</head>
<body>
Welcome to USA Map<br><br>
Click on Map to find out <br><br>
<script type="text/javascript">
$(function() { //run when the DOM is ready
    $("#planetmap area").click(function (e) {
    // jQuery code, event handling callbacks here
 alert();
});
});
</script>
<select id="listbox" size="5" multiple>
<option value="none">Take a pick on the map</option>
<option value="wyoming">Wyoming</option>
<option value="arizona">Arizona</option>
</select>
<img src="usaStateMap.jpg" alt="usa" usemap="#planetmap"/>
<map name="planetmap" id="planetmap">
<area id="wyoming" alt="Wyoming" title="Wyoming" href="#" shape="poly" 
coords="203,125,192,188,278,198,284,136" />
<area id="arizona" alt="Arizona" title="arizona" href="#" shape="poly" 
coords="138,258,118,330,188,361,201,269" />
</map>
</body>
</html>

地图将在子窗口中启动,列表框将在父窗口中启动。在 Javascript 的点击事件中,我希望能够在列表框中多选相同的项目(状态)。你能帮忙吗?

<script src="jquery.js"></script>
<script type="text/javascript">
 $(function() { //run when the DOM is ready
 $("#planetmap area").click(function (e) {
 // jQuery code, event handling callbacks here
   $('#mymapselect option[value="' + this.id + '"]').attr('selected', 'selected');
 });
 });
</script>

我从 http://learn.jquery.com/about-jquery/how-jquery-works/#jQuery:_The_Basics 下载了jquery.js文件并添加为参考。现在,单击事件适用于图像映射区域。它多选列表框中的项目。