新しい Jquery チェック ボックスをオンにすると、テキストを div コントロールに挿入しています。「チェックボックス」のチェックを外したときにそのテキストを削除したい
<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 コード:
$(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);
});
});