Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

change cover photo with javascript

//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 :: react component key prop 
Javascript :: how to use datepicker apply to send a get request 
Javascript :: Material-ui wallet icon 
Javascript :: js how to get element csswidth 
Javascript :: selialize jquery 
Javascript :: lodash get first element of array 
Javascript :: require cycle disable warning react native 
Javascript :: mongodb js insertmany 
Javascript :: Replacing String Content 
Javascript :: return js 
Javascript :: js variables 
Javascript :: how to connect socket in react js 
Javascript :: javascript and json 
Javascript :: jsfuck 
Javascript :: only allow requests from domain express 
Javascript :: itsycal homebrew 
Javascript :: random email js 
Javascript :: how to learn react 
Javascript :: using while loop to create table rows js 
Javascript :: jquery slick drag goes back 
Javascript :: How to get maximum value in Javascript 
Javascript :: how to add multiple style attributes in react element 
Javascript :: Yan Nesting For Loops 
Javascript :: javascript code to test if screen is idle 
Javascript :: fabric js 
Javascript :: reset regex javascript 
Javascript :: remove property from object javascript 
Javascript :: babel compile files empty 
Javascript :: index and id together angularjs 
Javascript :: sort array of objects based on another array javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =