Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

change image on click javascript

function changeImage() {
    if (document.getElementById("imgClickAndChange").src == "http://www.userinterfaceicons.com/80x80/minimize.png"){
        document.getElementById("imgClickAndChange").src = "http://www.userinterfaceicons.com/80x80/maximize.png";
    } else {
        document.getElementById("imgClickAndChange").src = "http://www.userinterfaceicons.com/80x80/minimize.png";
    }
}
Comment

changement image js sur click

let myImage = document.querySelector('img');

myImage.onclick = function() {
    let mySrc = myImage.getAttribute('src');
    if(mySrc === 'images/firefox-icon.png') {
      myImage.setAttribute('src','images/firefox2.png');
    } else {
      myImage.setAttribute('src','images/firefox-icon.png');
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: promise in es6 
Javascript :: mui date picker 
Javascript :: promise js 
Javascript :: remove string from outside array javascript 
Javascript :: how javascript run in browser 
Javascript :: sequelize 
Javascript :: upload file from url javascript 
Javascript :: Showing a custom toast function for react-toastify - Toast show 
Javascript :: css javascript 
Javascript :: useref example 
Javascript :: trimend in javascript 
Javascript :: v-show example in vue js 
Javascript :: read string using stream nodejs 
Javascript :: recordrtc 
Javascript :: document.getelementsbyname 
Javascript :: isnan 
Javascript :: download file using javascript 
Javascript :: find if json property is of type date type 
Javascript :: do while in js 
Javascript :: simple todo list javascript 
Javascript :: js some 
Javascript :: javascript object methods 
Javascript :: redis pub or sub nodejs 
Javascript :: node red json array 
Javascript :: jquery accordion toggle close open 
Javascript :: how to compile javascript 
Javascript :: javascript prototype vs constructor function 
Javascript :: divisible check javascript 
Javascript :: file upload in node js 
Javascript :: Why my array resets itself when I leave my function 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =