我仍然在学习jQuery,并遇到了一些我似乎无法解决的问题。我试图切换位于页面其他位置的div中复选框的标签。到目前为止,我已经设法追加标签只有当复选框未选中,但我不知道如何删除文本该筛选器只有,如果它变成未选中。有什么建议?jquery基于复选框状态在div中切换文本
JQUERY:
$('.filter-single').on('click', function() {
if ($('.filter-single input').is(':checked')) {
$('<li>'+$(this).text()+'/</li>').appendTo('.filters-current');
} else {
// what goes here?
}
});
FILTER HTML:
<div class="checkbox filter-single">
<input type="checkbox" value=".rain"/>
<label>Rain</label>
</div>
LABEL HTML:
<div class="filter-details">
<span class="filter-title">Filters:</span>
<ul class="filters-current"></ul>
</div>
正是我一直在寻找的那就没办法了!每天学些新东西 :) –