【发布时间】:2011-12-31 06:20:14
【问题描述】:
我想在我给了 span 元素的字符上画圆圈。我已经让它与一个元素一起工作(见注释代码)。我只想通过每个跨度元素来做到这一点。 首先,我首先尝试悬停,但我已经失败了。就悬停而言,它应该在调用函数 draw get 时发生。
function draw() {
ctx.save();
ctx.translate(plotX1, 0);
$("p").find("span").hover(function(){
console.log("hover");
var x = $(this).offsetLeft;
var y = $(this).offsetTop;
y += $(this).offsetHeight;
ellipse(ctx, x, y, 10);
ctx.strokeStyle = "rgba(200, 0, 0, 50)";
ctx.stroke();
});
ctx.restore();
/*
// this worked on the element with id s2
var x = s2.offsetLeft;
var y = s2.offsetTop;
y += s2.offsetHeight;
ctx.fillStyle = "rgb(0, 250, 0)";
//ctx.fillRect(x, y, 10, 10);
ellipse(ctx, x, y, 10);
ctx.strokeStyle = "rgba(200, 0, 0, 50)";
ctx.stroke();
*/
}
【问题讨论】:
标签: javascript jquery html html5-canvas