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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -