我有一个已经填充了结果的表。我还有一个我想用来操作表格内容的复选框。
复选框:
分支
- 一个
- 乙
- C
我的桌子看起来像这样
- 姓名|年龄|分公司
- 亚当,12,一个
- 地理,20,乙
我希望能够根据检查的内容在表中删除和添加一行。到目前为止,我是 jQuery 的新手:有什么帮助吗?
function sortByBranch() {
j$('#sfiltersb li label input[type="checkbox"]').bind("change", function(){
if(j$(this).hasAttr("checked"){
//do something
}
});
}
HTML
<ul id="haystack" class="slist">
<li><label class="checkbox" style="cursor:pointer;"><input type="checkbox" name="branch-aa" value="AA" checked="checked" class="scritb" />Branch AA</label></li>
<li><label class="checkbox" style="cursor:pointer;"><input type="checkbox" name="branch-ab" value="AB" checked="checked" class="scritb" />Branch AB</label></li>
<li><label class="checkbox" style="cursor:pointer;"><input type="checkbox" name="branch-ac" value="AC" checked="checked" class="scritb" />Branch AC</label></li>
<li><label class="checkbox" style="cursor:pointer;"><input type="checkbox" name="branch-ba" value="BA" checked="checked" class="scritb" />Branch BA</label></li>
<li><label class="checkbox" style="cursor:pointer;"><input type="checkbox" name="branch-bb" value="BB" checked="checked" class="scritb" />Branch BB</label></li>
<li><label class="checkbox" style="cursor:pointer;"><input type="checkbox" name="branch-bc" value="BC" checked="checked" class="scritb" />Branch BC</label></li>
<li><label class="checkbox" style="cursor:pointer;"><input type="checkbox" name="branch-ca" value="CA" checked="checked" class="scritb" />Branch CA</label></li>
<li><label class="checkbox" style="cursor:pointer;"><input type="checkbox" name="branch-cb" value="CB" checked="checked" class="scritb" />Branch CB</label></li>
<li><label class="checkbox" style="cursor:pointer;"><input type="checkbox" name="branch-cc" value="CC" checked="checked" class="scritb" />Branch CC</label></li>
<li><label class="checkbox" style="cursor:pointer;"><input type="checkbox" name="branch-da" value="DA" checked="checked" class="scritb" />Branch DA</label></li>
<li><label class="checkbox" style="cursor:pointer;"><input type="checkbox" name="branch-db" value="DB" checked="checked" class="scritb" />Branch DB</label></li>
<li><label class="checkbox" style="cursor:pointer;"><input type="checkbox" name="branch-dc" value="DC" checked="checked" class="scritb" />Branch DC</label></li>
</ul>
<button type="submit" class="btn" id="branch-search-btn" style="width:100%; font-size:13px; min-height:30px;">Search</button>