开发者

Circles and click events in Raphaël graphic library

开发者 https://www.devze.com 2023-03-15 18:07 出处:网络
I\'m trying to use Raphaël JS library. I just want to have some circles and change their color when user clicks on them. But I cannot understand why my code doesn\'t work. What\'s wrong with it?

I'm trying to use Raphaël JS library. I just want to have some circles and change their color when user clicks on them. But I cannot understand why my code doesn't work. What's wrong with it?

Code here http://jsfiddle.net/Xj4GA/ and below.

 window.onload = function () {

                var paper = Raphael(0, 0, 640, 480);

                circles = paper.set();

                circles.push(paper.circle(20, 20, 10));  
                circles.push(开发者_如何学Cpaper.circle(30, 30, 10));
                circles.push(paper.circle(50, 60, 10));
                circles.push(paper.circle(120, 420, 10));
                circles.push(paper.circle(520, 20, 10));
                circles.push(paper.circle(230, 280, 10));
                circles.push(paper.circle(320, 260, 10));

                for (var i = 0; i < circles.length; i++) {
                    circles[i].click(function () {
                        alert('balblaba');
                        //this.attr("stroke", "Red");
                    });
                }
}


fill it circles.attr({fill: "red"});

0

精彩评论

暂无评论...
验证码 换一张
取 消