Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js code to change a immage

<script type="text/javascript">
    function changeImage(a) {
        document.getElementById("img").src=a.src;
    }
</script>
<div id="main_img">
    <img id="img" src="1772031_29_b.jpg">
</div>
<div id="thumb_img">
    <img src='1772031_29_t.jpg'  onclick='changeImage("1772031_29_b.jpg");'>
    <img src='1772031_55_t.jpg'  onclick='changeImage("1772031_55_b.jpg");'>
    <img src='1772031_53_t.jpg'  onclick='changeImage("1772031_53_b.jpg");'>
</div>
Comment

changing photo with js

//ui
<form action="" method='post'>
  <img src="https://www.freeiconspng.com/uploads/no-image-icon-13.png" id="coverPreview" alt="">
  <input type="file" id="cover" />
</form>

//css
input{
  display:none;
}

//js
 let coverPreview = document.getElementById('coverPreview');
        let cover = document.getElementById('cover');

        coverPreview.addEventListener('click',_=>cover.click());

        cover.addEventListener("change",_=>{
            let file = cover.files[0];
            let reader = new FileReader();
            reader.onload = function (){
                coverPreview.src = reader.result;
            }
            reader.readAsDataURL(file);
        });
Comment

PREVIOUS NEXT
Code Example
Javascript :: switch case statement in javascript 
Javascript :: disable textbox on plumsail 
Javascript :: hot to set file views in nodejs 
Javascript :: [JsonConverter(typeof(StringEnumConverter))] on list of enums 
Javascript :: how to transform object in string with scaped 
Javascript :: find the height of space above element using javascript 
Javascript :: javascript create date object for midnight for a timezone 
Javascript :: react-datepicker float position 
Javascript :: how to read with attr in jquery 
Javascript :: loops javascript 
Javascript :: recoil js 
Javascript :: mongodb populate 
Javascript :: 2d array in javascript 
Javascript :: javascript only allow numbers 
Javascript :: jquery default value 
Javascript :: how to join kak in javascript 
Javascript :: javascript function to sleep 
Javascript :: javascript unary plus and negation operators 
Javascript :: create a drop down to select time javascript 
Javascript :: regex pattern to validate phone number in jitterbit 
Javascript :: javascript add item by index 
Javascript :: usestate with object 
Javascript :: add a string regex in angular input 
Javascript :: cant see serviceWorker.js 
Javascript :: how to use react memo hooks 
Javascript :: identity-obj-proxy not working 
Javascript :: javascript optional parameters 
Javascript :: how to loop through all tags in html 
Javascript :: es6 arrow function 
Javascript :: const { something} javascript 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =