Javascript-форум (https://javascript.ru/forum/)
-   Events/DOM/Window (https://javascript.ru/forum/events/)
-   -   как удалить фото из превью? (https://javascript.ru/forum/events/33713-kak-udalit-foto-iz-prevyu.html)

Mukhtar 05.12.2012 06:25

как удалить фото из превью?
 
Доброе утро.
Я сделал превью картинок перед загрузкой. Вот код:

<input type="file" name="file[]" multiple="true" id="files" />
<div id="images"></div>​​​​​​​​​​​​​​​​​​​​​​


var reader = new FileReader(),
    i=0,
    numFiles = 0,
    imageFiles;

// use the FileReader to read image i
function readFile() {
    reader.readAsDataURL(imageFiles[i])
}

// define function to be run when the File
// reader has finished reading the file
reader.onloadend = function(e) {

    // make an image and append it to the div
    var image = jQuery('<img style="width:100px; height:inherit; margin:3px;">').attr('src', e.target.result);
    jQuery(image).appendTo('#images');

    // if there are more files run the file reader again
    if (i < numFiles) {
        i++;
        readFile();
    }
};

jQuery('#files').change(function() {

    imageFiles = document.getElementById('files').files
    // get the number of files
    numFiles = imageFiles.length;
    readFile();           

});


Теперь пытаюсь сделать удаление изображений из превью. Помогите пожалуйста, очень горит.

Заранее спасибо

Mukhtar 05.12.2012 10:40

Походу никто не сможет помочь?

lord2kim 05.12.2012 13:02

Mukhtar, просто удалить их по нажатию на кнопку или что?
пробегитесь по всем тегам img в div id="images" и удалите ну или просто очистите div


Часовой пояс GMT +3, время: 18:45.