点击按钮#btn-modal-clear
时,我想选择一个类并将其添加到li
,其中sub-child
输入为空(value="")
。我该怎么做?
HTML:
<li>...<li>
<li>
<a class="myCheckboxLink" tabindex="0">
<span class="myCheckboxSpan">
<i class="fa fa-check fa-check-checkbox" aria-hidden="true"></i>
</span>
<label class="radio">
<input value="" type="radio">Name
</label>
</a>
</li>
<li>...<li>
JS:
$('#btn-modal-clear').on('click', function() {
$('.select-name').multiselect('select', ['']);
$('.select-name').multiselect('updateButtonText');
... .addClass("active");
});
结果应该是:
HTML:
<li>...<li>
<li class="active">
<a class="myCheckboxLink" tabindex="0">
<span class="myCheckboxSpan">
<i class="fa fa-check fa-check-checkbox" aria-hidden="true"></i>
</span>
<label class="radio">
<input value="" type="radio">Name
</label>
</a>
</li>
<li>...<li>
答案 0 :(得分:1)
在这种情况下,您可以class Fruit(BaseModel):
fruit_id= CharField()
name = Charfield()
color= ForeignKeyField(column_name='color', field='color', model=Color, null=True)
class Meta:
table_name = 'fruit'
与.filter()
一起使用:
.addClass()
答案 1 :(得分:1)
试试这个
$('li input[value=""]').closest("li").addClass('active');