Answers for "how to swap two images in javascript"

0

how to swap two images in javascript

<img src="ble.jpg" id="F" data-value="" onclick="swap(5)" />
<img src="ilk.jpg" id="4" data-value="2" onclick="swap(6)"/>

var img_1_value = document.getElementById("F").getAttribute('data-value');
var img_2_value = document.getElementById("4").getAttribute('data-value');

document.getElementById("F").setAttribute('data-value', img_2_value);
document.getElementById("4").setAttribute('data-value', img_1_value);
Posted by: Guest on October-28-2020

Code answers related to "how to swap two images in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language