Here is the html code
<p class="col-lg-24 col-md-24 col-sm-24 col-xs-24 color"> <span class="fa fa-square fa-4x colorinput" style="color:#ff9900" data-color="91822"></span> <span class="fa fa-square fa-4x colorinput" style="color:#4a86e8" data-color="91823"></span> </p> Thus, I create an element <strong class="fa fa-times-circle colorinputremove"></strong>
$('.colorinput').click(function () { var colorId = $(this).attr('data-color'); console.log(colorId); var addIcon='<strong class="fa fa-times-circle colorinputremove"></strong>'; $(this).html(addIcon); }); thus trying to delete the created object - the object <strong class="fa fa-times-circle colorinputremove"></strong>
$(".colorinput").on('click','colorinputremove',function () { var colorId = $(this).parent('.colorinput').attr('data-color'); console.log(colorId); $(this).parent('.colorinput').empty(); }) but he fails to remove it. However, the following code:
var colorId = $(this).parent('.colorinput').attr('data-color'); console.log(colorId); displays the numbers in the data-color attribute of the element's parent in the console. Expected output data-color parent element and the removal of the element.
console.logto both functions and see that when clicked, they both are called - Grundyhtmland write what it means it cannot remove it but it works out - what result is expected and what is it in reality? - Grundy