1

我正在使用 jquery,当鼠标悬停在具有 data-code=GB 属性的元素上时,如何触发警报?

我试过这个没有运气...

  $(".jvectormap-container path[data-code='GB']").mouseover(function(){
     alert('test');
  });

谢谢

4

4 回答 4

1

稍作修改,它对我有用。我补充说——

<head>
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 <script>
   $(document).ready(function(){
     $('.jvectormap-container path[data-code="GB"]').bind('mouseover', function(){
       alert('test');
     });
   });
  </script>
</head>

工作副本在这里:http: //jsbin.com/uwatiz/5/edit

于 2012-10-04T21:05:00.400 回答
1

为什么不使用 jVectorMap 的标准参数onRegionOver?您的代码在 IE 中不起作用,因为 IE 中没有path元素,而是使用它shape

于 2012-10-07T10:54:45.937 回答
0

你有一个div内的路径。这是错误的。通过正确使用路径,您的 js 代码可以正常工作。

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" class="jvectormap-container">
 <path d="M150 0 L75 200 L225 200 Z" data-code='GB' />
</svg>
于 2012-10-04T20:56:28.087 回答
0

试试这个

$(function() {
    $(".jvectormap-container").filter("path[data-code='GB']").on('mouseover',function(){
        alert('test');
    });
});
于 2012-10-04T21:24:12.917 回答