I have the following html markup:
//this is in ajax success result
success: function(response) {
if(response.success) {
$("[data-input='" + response.field + "']").parents('.file-wrapper').find("[data-item='" + response.item + "']").remove();
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="form-group">
<label class="col-md-2 director-label-file" for="director_front_passport">Front ID/Passport</label>
<div class="col-md-8 file-wrapper">
<input type="file" name="director_front_passport[]" class="app-file valid" data-item="1" aria-required="true" aria-invalid="false">
<label class="file-upload" for="director_front_passport"><span>Upload a File</span></label>
<div data-input="director_front_passport" class="file-name"><span class="image_wrapper"><span data-num="0" class="image_name">Link to image.jpeg</span><span title="Remove" data-placement="top" data-toggle="tooltip" class="glyphicon glyphicon-remove remove-file"></span></span></div><label id="director_front_passport[]-error" class="error" for="director_front_passport[]"></label>
</div
In ajax response I have:
{"success":true,"errors":false,"field":"director_front_passport","num":"0","item":"1"}
I want to find element with name=director_front_passport (or with data-input = director_front_passport - it's the same) and after that to find element with data-item = response.item which in this case = 1.
How to find it? I tried in this way.
data-input=director_front_passportbut also withdata-item =. I found this input with :$("[data-input='" + response.field + "']") . But how to add condition also this field to havedata-item=1?