简体   繁体   中英

clear image in only one dropify

Dropify from Github

Anybody can help me with this? I want to manually remove uploaded image inside this dropify. I have more than one dropify in a page. Whenever I try to remove, all of the images inside each dropify will be removed.

Can someone help me? Because I think this library is already inactive.

Whenever I use this code in one dropify, all other dropify images will also be removed.

$(".dropify-clear").click(); 

$(".dropify-clear").trigger("click"); worked for me

Get the parent wrapper of the element with the id, then trigger the click on the remove button.

for example

$('#image1').parent().find(".dropify-clear").trigger('click');

".dropify-clear" refers to all elements with the class name dropify-clear .

You should add an id to the specific element you want to remove and then refer to it in jQuery like this: "#idName"

Although its late to answer this question but I want to share my knowledge with others. You can face two situation when you will have to do this. I am sharing method for both situations.

  1. When there is a single dropifyin your file
  2. When there are multiple dropify in your file

Solution for 1 dropify:

    $(".dropify-clear").trigger("click");

Solution for multiple dropifies:

    $("#imageid").next(".dropify-clear").trigger("click");

Or if multiple dropifies in loop

    $(this).next(".dropify-clear").trigger("click");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM