html - Javascript code for remove image -
i want make javascript code when click "remove image" link , remove image. please me.
<script> function previewfile(){ var preview = document.queryselector('img'); var file = document.queryselector('input[type=file]').files[0]; var reader = new filereader(); reader.onloadend = function () { preview.src = reader.result; } if (file) { reader.readasdataurl(file); } else { preview.src = ""; } } previewfile(); </script> <input type="file" onchange="previewfile()"><br> <img src="" height="200" alt="image preview..."> <a href="#">remove image </a> </body> </html>
<img id='image' src="" height="200" alt="image preview..."> <a id='remove' href="#">remove image </a> <script> $(function rmv() { $('#remove').click(function() { $('#image').remove(); } }); </script>
Comments
Post a Comment