I have a following HTML code:
<div id="image-preview1" class="col-xs-2 ">
<div id="buttonPlace1"></div>
<div>
<label for="image-upload1" id="image-label1">Upload photo</label>
<input type="file" name="image" id="image-upload1">
</div>
</div>
and
$('#image-upload1').change(function() {
$('#buttonPlace1').append("<button id='closeBtn1' onclick='btnRemove1()' class='btn deleteButton'>X</button>");
})
function btnRemove1(){
$('#buttonPlace1').empty();
}
This works fine. Button is added and removed on click..
But when I remove onclick event from <button>
and change btnRemove()
to:
$('#closeBtn1').click(function() {
$('#buttonPlace1').empty();
})
button removing on click stops working. I'm at very beginnig of JS an jQuery and i can't figure it out. Help please >:|