javascript - jquery点击功能选择和取消选择

标签 javascript jquery

我需要一些有关此 jQuery 代码的帮助。我有一张 SVG map ,我需要单击一下选择一个国家,然后再单击一次取消选择。有人可以帮我吗? :) 这是代码:

<script type="text/javascript">//<![CDATA[ 
$(window).load(function(){
$(document).ready(function() {




 $("path").mouseover(function() {
     $(this).css('cursor', 'pointer');$(this).attr({
    fill: "#FF0000",
    stroke: "#00FF00"
     });
     $(this).css('cursor', 'pointer');
    })
 .mouseout(function(){
     if(!$(this).data('clicked')){
       $(this).attr({
    fill: "#FFFFFF",
    stroke: "#eee"
    });
    } 
  });


$("path").click(function() {
$(this).attr({
    fill: "#FF0000",
    stroke: "#00FF00"
});
$(this).data('clicked', true); 

});

});
});//]]>  

</script>

最佳答案

最重要的方法是使用:http://api.jquery.com/toggle-event/

关于javascript - jquery点击功能选择和取消选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12439143/

相关文章:

javascript - 点击并打开表格

javascript - AJAX html stub ——加载清除的 head 元素是否实用?

javascript - AJAX 弹出窗口在 IE 中被阻止,但在 FF 中未被阻止

javascript - jQuery 和 <dialog> 元素

jquery - 计算每个鼠标滚轮滚动并输出到变量

javascript - DataTables 中显示行的限制

php - 直接从 JavaScript 访问 GET?

javascript - html/js 中从右到左和/或从上到下的文本?

javascript - 从对象数组中获取具有总和的不同项目

javascript - 如何在 JavaScript 中检测 SharePoint 2013/2016 身份验证模式