html是动态的,一个例子是:
<ul class="list-group">
<li class="list-group-item">
<div class="checkbox">
<label>
<input type="checkbox" value="693b32d9-d776-4df2-bf78-bd3412d9945b" name="permissions">
A / B
<span class="label label-info invisible">X</span>
</label>
</div>
</li>
<li class="list-group-item">
<div class="checkbox">
<label>
<input type="checkbox" checked="checked" value="b70a2218-6af1-4a5a-a6cf-1454df039d24" name="permissions">
A / B / C
<span class="label label-info invisible">X</span>
</label>
</div>
</li>
<li class="list-group-item">
<div class="checkbox">
<label>
<input type="checkbox" value="db5ffc0f-6733-4d65-a5f0-aafd6411cd8e" name="permissions">
A / B / C / D
<span class="label label-info">Y</span>
<span class="label label-info invisible">X</span>
</label>
</div>
</li>
<li class="list-group-item">
<div class="checkbox">
<label>
<input type="checkbox" value="b08f35be-9e21-4f37-9997-b9dce3b91356" name="permissions">
A / B / E
<span class="label label-info">Y</span>
<span class="label label-info invisible">X</span>
</label>
</div>
</li>
</ul>
答案 0 :(得分:0)
您可以使用data
属性。
<div class="checkbox">
<label data-a data-b>
<input type="checkbox" value="693b32d9-d776-4df2-bf78-bd3412d9945b" name="permissions" >
A / B
<span class="label label-info invisible">X</span>
</label>
</div>
因此,当带有“a”字样的项目发生变化时,数据“a”的所有时间也会发生变化。
$('[data-a] input').on('change', function() {
$('ul').find('[data-a] span.label').removeClass('invisible');
}