简体   繁体   中英

Rotate image Raphael.js

I have the following jQuery:

var paper = Raphael(0, 20, 500, 500);

var robot = paper.image("http://jackdent.co.uk/arrow-right.jpg", 0, 0, 20, 20);
robot.node.setAttribute('id', 'robot');

$('#submit').on('click', function () {
    $('#robot').rotate(90);
})

​I need for certain reasons to access the robot element using an id assigned to it. I want to rotate the image 90 degrees when the client clicks a button. Currently my code is erroneous, and I can't figure out why.

Any help would be much appreciated, thanks in advance.

See a live example here

Use:

robot.rotate(90);

instead of

$('#robot').rotate(90);

Demo: http://jsfiddle.net/Vre9W/18/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM