Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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);
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery ajax true false as boolean value 
Javascript :: remove storybook from project 
Javascript :: react input cursor jump end 
Javascript :: react router go back 
Javascript :: send data using fetch 
Javascript :: remove a value to an array of javascript 
Javascript :: javascript open window 
Javascript :: double logical not javascript 
Javascript :: array check in javascript 
Javascript :: two sum js 
Javascript :: javascript object type 
Javascript :: mongodb date format dd/mm/yyyy 
Javascript :: how to create an element in js using the map method 
Javascript :: how can hide link from inspect element 
Javascript :: angular scroll to element horizontally 
Javascript :: random number generatoe js 
Javascript :: swap scroll right in react native 
Javascript :: css select all links in div 
Javascript :: redux toolkit 
Javascript :: what does = mean in javascript 
Javascript :: node cron install 
Javascript :: google autocomplete not returning lat long 
Javascript :: jquery ajax download file 
Javascript :: center canvas p5js 
Javascript :: react-dropzone 
Javascript :: cek versi node js 
Javascript :: position of the mouse cursor javascript 
Javascript :: fibonacci numbers 
Javascript :: how to count seconds in javascript 
Javascript :: template literal syntax 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =