This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="file" name="cover"> | |
<img id="cover_preview" src=""> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 選圖片更新預覽圖 | |
$("input[name=cover]").on("change", function(){ | |
if (this.files && this.files[0]) { | |
var reader = new FileReader(); | |
reader.onload = function (e) { | |
$("#cover_preview").attr('src', e.target.result); | |
} | |
reader.readAsDataURL(this.files[0]); | |
} | |
}); |
沒有留言:
張貼留言