gpt4 book ai didi

javascript - 使用 Raphael JS 制作可点击对象

转载 作者:行者123 更新时间:2023-11-28 13:47:55 24 4
gpt4 key购买 nike

我创建了一个 3d 外观的圆圈,并希望它可以点击并显示其数据。我似乎无法让它工作。有人可以帮我解决这个问题吗???我尝试执行此操作的代码靠近底部....

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Raphaël · Ball</title>
<link rel="stylesheet" href="demo.css" type="text/css" media="screen">
<link rel="stylesheet" href="demo-print.css" type="text/css" media="print">
<script src="raphael.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
Raphael.fn.ball = function (x, y, r, hue) {
hue = hue || 0;
return this.set(
//this part is the drop shadow
this.ellipse(x, y + r - r / 5, r, r / 2).attr({fill: "rhsb(" + hue + ", 1, .25)-hsb(" + hue + ", 1, .25)", stroke: "none", opacity: 0}),
//this part is the top part of the circle
this.ellipse(x, y, r, r).attr({fill: "r(.5,.9)hsb(" + hue + ", 1, .75)-hsb(" + hue + ", .5, .25)", stroke: "none"}),
//this is the inner glow part from the top
this.ellipse(x, y, r - r / 5, r - r / 20).attr({stroke: "none", fill: "r(.5,.1)#ccc-#ccc", opacity: 0})
);
};
window.onload = function () {
var R = Raphael("holder"), x = 300, y = 100, r = 100;
//I cant tell what numbers are passed into here?????
R.ball(x, y, r, Math.random()).data("i", i).click(function () {
alert(this.data("i"));
});
};
</script>
</head>
<body>
<div id="holder"></div>
</body>
</html>

最佳答案

如果我在这里弄错了,我深表歉意......但是这段代码的示例对我来说工作正常......不幸的是,我似乎无法在你的代码中找到 var i传递给 data('i',i) .... declare var i = something; 或者试试这个 data('i','Hello') 让你知道它有效...希望它有所帮助。

jsFiddle

关于javascript - 使用 Raphael JS 制作可点击对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11694104/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com