Changing image on click Raphael paper -
i have program user can add images paper, using raphael. want able change image image when clicked. possible? have add id images? if so, how?
var imgurl = "img/img.png"; var banknoteimg = new image(); banknoteimg.src = imgurl; var width = banknoteimg.width; var height = banknoteimg.height; var image = paper.image(imgurl, x, y, width, height);
use click , attr function of raphael api.
element.click take function parameter. use this
access image element inside function.
i created simple demo
var paper = raphael(document.getelementbyid("papercanvas"), 200, 200); var img = paper.image(url1, 100, 100, 100 , 100); function changeimagesource() { this.attr('src', url2); } img.click(changeimagesource);
Comments
Post a Comment