I am trying to create something like stackoverflow.com tag cloud. I am able to display the tags but stuck on how to capture which tag element cancel button was clicked.
The cancel buttons are created dynamically using jquery on click of btnAdd
.
$("#<%=btnAdd.ClientID%>").on('click',function(){
var tagText = $('#<%=txtTag.ClientID%>').val();
var btnCancel = '<button class="btn btn-default">X</button>';
var tagTextDiv ='<div class="tagElement">' + tagText + btnCancel +'</div>';
$("#divTagCloud").append(' ' + tagTextDiv);
});
HTML is
<div class="col-xs-12 col-sm-6">
<asp:TextBox runat="server" />
</div>
<div class="col-xs-12 col-sm-6">
<asp:Button runat="server" id="btnAdd"/>
</div>
<div class="col-xs-12 col-sm-12">
<div id="divTagCloud"></div>
</div>
I want to remove the tag i.e corresponding tagTextDiv
on click of corresponding cancel button.
How to do this ?