我有一个盒子。当您将鼠标放在框上时,框顶部会出现一个按钮。悬停功能的工作方式是它无法识别鼠标仍在框的顶部。我该如何解决?
//I create the paper
var paper = Raphael(0, 0, 500,500);
//I add the box
var box = paper.add([{
type: "rect",
x: 100,
y: 100,
width: 100,
height: 100,
fill: '#000',
}])
// I declare a varible for the button
var button
//I add hover functions to the box.
//first function: when the mouse is on, create a red circle and add an
//onclick event to the circle
box.hover(function () {
button = paper.circle(150, 150, 25).attr({ 'fill': 'red' })
button.click(function () { alert("You clicked me!")})
},
//second function: when the mouse leaves the box, remove the circle
function () {
button.remove()
})
这是一个例子