I have some html elements :
<img id="preview_image" alt="" src="" width="100px" height="120px">
<br>
<input type="file" name="user_image" id="user_image" onchange="preview(this);">
Here the js :
function preview(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#preview_image')
.attr('src', e.target.result)
.width(100)
.height(120);
};
reader.readAsDataURL(input.files[0]);
}
}
When I select an image, it will be preview immediately.
All that I want now is : at first, select an image (but not preview right now) , then click on a hyperlink, the image will be displayed. The hyperlink is something like this :
<a href="javascript:void(0)" onclick="preview2()">Click to preview</a>
preview2 = function(){
//what should I do here (using Jquery)
}
Thank you so much!