new Jquery I am inserting text to div control,when check box checked. and i want to remove that text when uncheck `checkbox’
<div align="center" id="chkBoxes">
<asp:CheckBox ID="chbIceCream" text ="Ice Cream" runat="server"></asp:CheckBox>
<asp:CheckBox ID="chbCake" Text ="Cake" ClientIDMode="static" runat="server" />
<asp:CheckBox ID="chbChocolet" Text ="Cho colet" runat="server" />
</div>
<div id="ContentDiv">
</div>
Jquery Code:
$(document).ready(function () {
$('#chbIceCream').click(function () {
var Text = $("input:checkbox[id$=chbIceCream]").next().text();
if ($(this).attr('checked'))
$('#ContentDiv').append(Text);
else
$('#ContentDiv').remove(Text);
});
});
If you want to remove all the text from ContentDiv then see Matthew’s answer
if you want to remove specific text i.e. there is other text in that div too, which you do not want to remove. then use:
in your
elsepart