D3: How do I set “click” event and “dbclick” event at the same time?
问题 I've toggled click event to a node and I want to toggle a dbclick event to it as well. However it only triggers the click event when I dbclick on it. So How do I set both events at the same time? 回答1: You have to do your "own" doubleclick detection Something like that could work: var clickedOnce = false; var timer; $("#test").bind("click", function(){ if (clickedOnce) { run_on_double_click(); } else { timer = setTimeout(function() { run_on_simple_click(parameter); }, 150); clickedOnce = true;