当我使用raphael.js,jQuery点击地图上的特定美国州时,我无法定位SVG路径ID

时间:2016-12-16 15:05:04

标签: javascript jquery html google-maps svg

我想要实现的目标是当我在SVG MAP上点击特定的美国州时,我希望它更新iframe中的src属性值以在Google地图上加载特定的美国州。

当我尝试运行这个jQuery代码时,它不起作用:

$(document).ready(function() {
  $('path#0').on("click", function() {
   $('#mapRedirect').attr('src',paths[0].url);
  });
});

当我运行此代码时,它可以工作:

$(document).ready(function() {
  $(this).on("click", function() {
    $('#mapRedirect').attr('src',paths[0].url);
  });
}); 

我试图用它的路径ID定位的路径元素:

<path fill="#ff0000" stroke="#000000" d="M631.30647,460.41572L629.81587,446.09422L627.06763,427.34158L627.22929,413.27709L628.03759,382.23824L627.87593,365.58718L628.04102,359.16812L672.5255,355.54867L672.3777,357.73109L672.53936,359.83269L673.18601,363.22756L676.58089,371.14893L679.00579,381.01024L680.46074,387.15335L682.07734,392.00317L683.5323,398.95458L685.63388,405.25934L688.22045,408.65423L688.70543,412.04909L690.64537,412.8574L690.80703,414.95899L689.02875,419.80881L688.54377,423.04203L688.38211,424.98195L689.99873,429.3468L690.32205,434.68159L689.51373,437.10651L690.16039,437.91481L691.61533,438.72311L691.94347,441.61193L686.34581,441.25838L679.55606,441.90503L654.01366,444.81491L643.6021,446.22168L643.38072,449.09908L645.15899,450.87735L647.74556,452.81727L648.32642,460.75271L642.78436,463.32561L640.03614,463.00229L642.78436,461.06236L642.78436,460.0924L639.71282,454.11096L637.44957,453.46432L635.99462,457.82915L634.70134,460.57738L634.0547,460.41572L631.30647,460.41572Z" stroke-width="0" opacity="0" id="0" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); opacity: 0; cursor: pointer;"></path>

0 个答案:

没有答案