Hover over red dot. Mouse press the blue dot. Watch the console events.
xxxxxxxxxx
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v3.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
.red {
fill: red;
}
.blue {
fill: blue;
}
.orange {
fill: orange;
}
</style>
</head>
<body>
<p><a href="https://blockbuilder.org">Blockbuilder</a></p>
<script>
// Feel free to change or delete any of the code you see in this editor!
var svg = d3.select("body").append("svg")
.attr("width", 960)
.attr("height", 150)
svg.append("circle")
.attr("class", "red")
.attr("cx", 100)
.attr("cy", 75)
.attr("r", 20);
svg.append("circle")
.attr("class", "blue")
.attr("cx", 200)
.attr("cy", 75)
.attr("r", 20);
d3.select("circle.red")
.on("mouseenter", function (){
console.log("MOUSEENTER", this)
})
.on("mouseleave", function (){
console.log("MOUSELEAVE", this)
})
d3.select("circle.blue")
.on("mousedown", function (){
console.log("MOUSEDOWN", this)
})
// use namespace to register multiple handlers
// Otherwise the same handler will unregister the previous
.on("mousedown.second", function (){
console.log("MOUSEDOWN 2", this)
});
d3.select("a")
.on("click", function (){
d3.event.preventDefault();
})
// use namespace to register multiple handlers
// Otherwise the same handler will unregister the previous
.on("click.second", function (){
console.log("CLICKED 2", this);
});
</script>
</body>
https://d3js.org/d3.v3.min.js