我用Raphael创建了一张图像地图.当单击图像映射中的一个路径(下例中的path10)时,我希望包含Raphael画布的div淡出使用jQuery.下面的代码不起作用,但我是否在正确的轨道上?
<script type="text/javascript" charset="utf-8"> window.onload = function () { var R = Raphael("canvas",1050,550); var attr = { fill: "#bbb","fill-opacity": 1,stroke: "#222","stroke-width": 0.3,"stroke-linejoin": "round" }; path10 = R.path("m 221.63509,150.81487 97.24682,0 0,89.68452 -97.24682,-89.68452 z").attr(attr); }; path10.node.setAttribute("id","barry"); $(document).ready(function(){ $("#barry").click(function(){ $("#canvas").fadeOut(); }); }); </script> <body> <div id="canvas"></div> </body>
解决方法
差不多……这个有效(在Firefox 3.6.8上测试过):
<body> <script type="text/javascript" charset="utf-8"> $("document").ready(function() { var R = Raphael("canvas",-89.68452 z").attr(attr); path10.node.setAttribute("id","barry"); $("#barry").click(function(){ $("#canvas").fadeOut(); }); }); </script> <div id="canvas"></div> </body>