Click upload pictures, show preview (single image)

js code

 

 

// When the value of the element of change, change events occur.

$ ( "# Upload button id"). Change (function () {

  var reads = new FileReader();

  var f = document.getElementById ( "upload button id") files [0].;

  reads.readAsDataURL(f);

  reads.onload = function(){

    document.getElementById ( "id you want to display a large picture img tag") src = this.result.;

  }

)

 

Note: Some native js code above to obtain elements can not operate normally after the acquisition method of jquery replaced; code I do not quite understand the specific meaning, welcome to share

Guess you like

Origin www.cnblogs.com/PHP0222wangdong/p/11363066.html