118
rated 0 times
[
122]
[
4]
/ answers: 1 / hits: 86332
/ 10 Years ago, wed, december 3, 2014, 12:00:00
I have two images which I need to toggle on clicking on the image.
<img id='arrowRotate' src='images/prof_arrow1.png' data-swap='images/prof_arrow.png'
data-src='images/prof_arrow1.png' />
When the user click the image the src
should get the value of data-swap
and when you click again the src
should change to data-src
. This should keep happening just like a toggle. Any help appreciated.
$(#arrowRotate).click(function() {
var swapImage = $(#arrowGrey).attr(data-swap);
$(#arrowGrey).attr({
'src': swapImage,
id: 'arrowOrange'
});
});
This is where I have got so far.
More From » jquery