Element.mousemove(handler)
给元素添加鼠标经过事件。
参数
handler
函数。事件句柄。
返回值
对象。元素。
使用
<svg id="svg" width="100" height="100"></svg>
var svg = Snap("#svg");
var c = svg.paper.circle(50, 50, 40).mouseover(function() {
var color = randomColor();
this.attr({
fill: color // 变色
});
});
function randomColor(){
var r = Math.floor(Math.random()*256);
var g = Math.floor(Math.random()*256);
var b = Math.floor(Math.random()*256);
return "rgb("+r+","+g+","+b+")";
}
鼠标经过下面的圈圈