1つのdivに4つのチェックボックスがあります。
<div id="tab1" class="tab-pane">
<input type="checkbox" id="chkbox" value="101"> This is 101
<input type="checkbox" id="chkbox" value="102"> This is 102
<input type="checkbox" id="chkbox" value="103"> This is 103
<input type="checkbox" id="chkbox" value="104"> This is 104
</div>
クリックするたび<li>
に、チェックボックスがオン/オフになっているときに右側にある別のdivにアイテムを挿入/削除します。別のdiv:
<div id="items">
<ul id="itemList">
</ul>
このようなことをしています:
$("#chkbox").click(function() {
// If checked
if ($(this).is(":checked")) {
//add to the right
$a = $(this).val();
$("#itemList").append('<li>'+$a+'</li>');
}
else {
//hide to the right
$("#itemList").slideUp("fast", function () {
$("#itemList").child.remove();
});
}
});
これはうまくいかないようです:(