如何在選中時更改與複選框相對應的文本。我想在選中時將文本更改爲一個值,並在未選中框時將其恢復。如何更改文本標籤複選框引導?
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" >
<div class="container">
<div class="row">
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary ck">
<input type="checkbox"> off
</label>
<label class="btn btn-primary ck">
<input type="checkbox"> off
</label>
<label class="btn btn-primary ck">
<input type="checkbox"> off
</label>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script>
$('input[type=checkbox]:checked').on('change', function() {
$(this).text("on");
});
</script>