我想显示给定部门的前两个字段,即garage_quoted_amt和quoted_amt,所以请帮帮我。我是jquery的新手。
我已使用此条件显示以下条件
$("#priceDifference div.row:not(:nth-of-type(3))").show();
请以正确的方式指导我。
<div class="row" id="priceDifference" style="display:none;">
<div class="row">
<div class="col-lg-4 col-xs-1 col-lg-offset-1 form-group">
<label style="padding-top:5px;"> Quoted Price</label>
</div>
<div class="col-xs-4">
<div class="form-group">
<input type="number" name="quoted_amt" id="gobumpr_quoted_amt<?php echo $booking_id; ?>" class="form-control" style="max-width:280px;"/>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-4 col-xs-1 col-lg-offset-1 form-group">
<label style="padding-top:5px;"> Garage Quoted Price</label>
</div>
<div class="col-xs-4">
<div class="form-group">
<input type="number" name="garage_quoted_amt" id="garage_quoted_amt<?php echo $booking_id; ?>" class="form-control" style="max-width:280px;"/>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-4 col-xs-1 col-lg-offset-1 form-group">
<label style="padding-top:5px;"> Local Garage Quote</label>
</div>
<div class="col-xs-4">
<div class="form-group">
<input type="number" name="local_garage_quoted_amt" id="local_garage_quoted_amt<?php echo $booking_id; ?>" class="form-control" style="max-width:280px;"/>
</div>
</div>
</div>
</div>
最佳答案
1.从父div style="display:none;"
中删除<div class="row" id="priceDifference">
2.使用:gt() Selector
$("#priceDifference div.gt(1)").hide();
工作片段:-
$(document).ready(function(){
$("#priceDifference .row:gt(1)").hide();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="row" id="priceDifference"><!-- remove style="display:none;"-->
<div class="row">
<div class="col-lg-4 col-xs-1 col-lg-offset-1 form-group">
<label style="padding-top:5px;"> GoBumpr Quoted Price</label>
</div>
<div class="col-xs-4">
<div class="form-group">
<input type="number" name="quoted_amt" id="gobumpr_quoted_amt<?php echo $booking_id; ?>" class="form-control" style="max-width:280px;"/>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-4 col-xs-1 col-lg-offset-1 form-group">
<label style="padding-top:5px;"> Garage Quoted Price</label>
</div>
<div class="col-xs-4">
<div class="form-group">
<input type="number" name="garage_quoted_amt" id="garage_quoted_amt<?php echo $booking_id; ?>" class="form-control" style="max-width:280px;"/>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-4 col-xs-1 col-lg-offset-1 form-group">
<label style="padding-top:5px;"> Local Garage Quote</label>
</div>
<div class="col-xs-4">
<div class="form-group">
<input type="number" name="local_garage_quoted_amt" id="local_garage_quoted_amt<?php echo $booking_id; ?>" class="form-control" style="max-width:280px;"/>
</div>
</div>
</div>
</div>