我正在尝试实现一个JQuery脚本来处理图像映射中的一些区域.
我使用$(‘area [shape =“poly”]’)作为选择器来获取我感兴趣的区域.它在IE8和Firefox中运行良好,但它没有在IE6或IE7中选择元素.
这是一个显示此问题的测试页面.我不知道这是一个JQuery错误还是我做错了什么.
我使用$(‘area [shape =“poly”]’)作为选择器来获取我感兴趣的区域.它在IE8和Firefox中运行良好,但它没有在IE6或IE7中选择元素.
这是一个显示此问题的测试页面.我不知道这是一个JQuery错误还是我做错了什么.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ $(document).ready(function() { var areas = $('area[shape="poly"]'); alert('areas: ' + areas.length); }); //]]> </script> <title>Test</title> </head> <body> <img id="img1" src="nothing.gif" style="width:300px; height:300px; border: 2px solid black" usemap="#map1"/> <map id="map1"> <area shape="rect" title="rectArea" coords="126,112,231,217" alt=""/> <area shape="poly" title="polyArea1" coords="274,72,262,70,251,68,240,67,228,66,217,206,194,183,181,63,192,60,204,58,216,57,56,252,264,276,63" alt=""/> <area shape="poly" title="polyArea2" coords="241,235,193,222,196,119,117,212,116,220,115,237,245,253,261,119" alt=""/> </map> </body> </html>
这在IE8和Firefox中显示2,在IE6-7中显示0
谢谢,
吉列尔莫
解决方法
如果你大写这个值似乎有效:
var areas = $('area[shape="POLY"]');
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。