我需要一些有关此 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/