靜態學習Bootstrap,我試圖用複選框創建一個輸入表單,其中任何複選框的下拉列表出現(對於特定的複選框)。我遇到的問題是每當出現下拉菜單時,都會將其他複選框轉移。我想阻止它,以便複選框固定到位,並且在下拉菜單出現時不會左右移動。Bootstrap動態下拉複選框格式
下面是HTML片段:
<div class="container-fixed">
<div class="row">
<div class="form-check col-xs-6" >
<label class="form-check-label">
<input type="checkbox" value="cheese" >cheese
<div class="form-group"id="cheese">
<label for="Quantity">How Much?</label>
<select class="form-control" >
<option>regular</option>
<option>Extra</option>
</select>
</div>
</label>
</div>
<div class="form-check col-xs-6" >
<label class="form-check-label">
<input type="checkbox" value="Broccoli" >Broccoli
<div class="form-group"id="Broccoli">
<label for="Quantity">How Much?</label>
<select class="form-control" >
<option>regular</option>
<option>Extra</option>
</select>
</div>
</label>
</div>
<div class="form-check col-xs-6" >
<label class="form-check-label">
<input type="checkbox" value="Peppers" >Peppers
<div class="form-group"id="Peppers">
<label for="Quantity">How Much?</label>
<select class="form-control" >
<option>regular</option>
<option>Extra</option>
</select>
</div>
</label>
</div>
這裏是jQuery的:
$(document).ready(function() {
$("input").click(function() {
var show = "#" + this.value
$(show).show();
})
})