Kann mir jemand sagen, wie HTML-Code anhängen, die Button-Element haben und diese Schaltfläche funktionsfähig machen? Warum funktioniert meine Funktion nicht auf der angehängten Schaltfläche?jQuery-Funktion nach dem Anhängen Element
Hier ist mein Code:
<div id="attachments">
<input id="add-attachment" type="button" value="Dodaj kolejny ✚" class="button-custom-3">
<div class="hr-custom-1"></div>
<div>
<input type="button" value="Przeglądaj" class="button-custom-1">
<span>Przykładowa nazwa załączonego pliku.jpg</span>
<input type="button" value="Usuń ✖" class="button-custom-2 button-remove-attachment">
<div class="hr-custom-1"></div>
</div>
<div>
<input type="button" value="Przeglądaj" class="button-custom-1">
<span>Przykładowa nazwa załączonego pliku.jpg</span>
<input type="button" value="Usuń ✖" class="button-custom-2 button-remove-attachment">
<div class="hr-custom-1"></div>
</div>
JavaScript-Funktionen:
$(".button-remove-attachment").click(function(){
$(this).parent().remove();
});
$("#add-attachment").click(function(){
var element = $("<div><input type='button' value='Przeglądaj' class='button-custom-1'><span>Przykładowa nazwa załączonego pliku.jpg</span><input type='button' value='Usuń ✖' class='button-custom-2 button-remove-attachment'><div class='hr-custom-1'></div></div>");
$("#attachments").append(element);
});
Bitte überprüfen Sie es auf jsFiddle: https://jsfiddle.net/6f9xhr64/
bitte genauer erklären, was genau Sie tun möchten. –
check jsFiddle bitte https://jsfiddle.net/6f9xhr64/ – Kamczatka