简体   繁体   English

旋转图像Raphael.js

[英]Rotate image Raphael.js

I have the following jQuery: 我有以下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. 出于某些原因,我需要使用分配给它的ID来访问机器人元素。 I want to rotate the image 90 degrees when the client clicks a button. 我想在客户端单击按钮时将图像旋转90度。 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/ 演示: http//jsfiddle.net/Vre9W/18/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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