Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jquery change picture onclick

<!-- https://codepen.io/poliweb/pen/eYJNqLM -->
<!-- https://stackoverflow.com/questions/26377231/jquery-how-to-change-img-src-path-onclick -->

<div class="img-container">
  <img id="changeMe" src="">
</div>

<img class="preview" src="images/preview-1.jpg">
<img class="preview" src="images/preview-2.jpg">
<img class="preview" src="images/preview-2.jpg">
  
 <!-- Script --> 
  
  $('.preview').on('click',  function() {
    $('#changeMe').prop('src', this.src);
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: type of variable js 
Javascript :: how To clear all the input element inside div using jquery 
Javascript :: modify margin top javascript 
Javascript :: what is niceScroll 
Javascript :: node js split data 
Javascript :: javascript open new window 
Javascript :: js omit last string 
Javascript :: access to xmlhttprequest at from origin http localhost:3000 has been blocked by cors policy 
Javascript :: how to get current date in js 
Javascript :: get the value or text from select element using javaScript 
Javascript :: Node Sass could not find a binding for your current environment 
Javascript :: calling javascript functions from unity scripts 
Javascript :: find email domain javascript 
Javascript :: load a page with ajax 
Javascript :: change image on hover js 
Javascript :: rgb to hex js 
Javascript :: last element in array javascript 
Javascript :: rounding off in javascript 
Javascript :: connect metamask with react app 
Javascript :: How to make the width of a react native element adjust according to the contents 
Javascript :: how to use sweet alert in vue js 
Javascript :: detect two strings are anagram of each other in JavaScript 
Javascript :: react toggle boolean state 
Javascript :: javascript infinite loop 
Javascript :: jquery validate conditional 
Javascript :: autocomplete react vscode 
Javascript :: angular contains both .browserslistrc and browserslist 
Javascript :: how to add jquery in js file 
Javascript :: dayjs timezone 
Javascript :: trigger window resize 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =