Page 1 of 1

on/off image

Posted: Thu Jun 20, 2013 10:01 am
by Dimitris Monastiriotis

hi, how can i set an image as an on/off switch (toggle)? what i mean is to have two images, display imageA and when click on it to display ImageB click again and display imageA etc etc. I tried by trying to set the asset property via the appery interface but nothing happens.
any ideas? thanx


on/off image

Posted: Thu Jun 20, 2013 12:26 pm
by Maryna Brodina

Hello! You would need to upload images to assets and on click on image run the following JS:
codeif ($(this).attr("src").indexOf('img1.png') > 0) {
$(this).attr("src", Appery.getImagePath("img2.png"))
} else {
$(this).attr("src", Appery.getImagePath("img1.png"))
}/code
where img1.png, img2.png - images names