The editor below will share with you a JS sample code to implement clicking on the check box to change the display status of p. It has a good reference value and I hope it will be helpful to everyone. Let’s follow the editor and take a look.
First of all, on the page:
<p class="row cl"> <label class="form-label col-xs-4 col-sm-3" style="width: 20%"><span class="c-red">*</span>是否存在促销活动:</label> <p class="formControls col-xs-8 col-sm-9 skin-minimal"> <p class="check-box"> <input type="checkbox" value="1" id="isHaveActive" > <label for="isHaveActive"> </label> </p> </p> </p> <p id="active" name="active" style="display:none;"> <p class="row cl" > <label class="form-label col-xs-4 col-sm-3" style="width: 20%"><span class="c-red">*</span>现价:</label> <p class="formControls col-xs-8 col-sm-9"> <input type="number" step="0.01" class="input-text" value="${priceChange.price}" placeholder="" id="price" name="price" > 元/L </p> </p> <p class="row cl" > <label class="form-label col-xs-4 col-sm-3" style="width: 20%"><span class="c-red">*</span>活动名:</label> <p class="formControls col-xs-8 col-sm-9"> <input type="text" class="input-text" value="${priceChange.active_name}" placeholder="" id="active_name" name="active_name" > </p> </p> <p class="row cl" > <label class="form-label col-xs-4 col-sm-3" style="width: 20%"><span class="c-red">*</span>距挂牌价:</label> <p class="formControls col-xs-8 col-sm-9"> <input type="number" step="0.01" class="input-text" value="${priceChange.gap_guapai}" placeholder="" id="gap_guapai" name="gap_guapai" > 元/L </p> </p> <p class="row cl" > <label class="form-label col-xs-4 col-sm-3" style="width: 20%"><span class="c-red">*</span>促销活动形式:</label> <p class="formControls col-xs-8 col-sm-9"> <input type="text" class="input-text" value="${priceChange.activity_form}" placeholder="" id="activity_form" name="activity_form" > </p> </p> <p class="row cl" > <label class="form-label col-xs-4 col-sm-3" style="width: 20%"><span class="c-red">*</span>促销活动优惠幅度:</label> <p class="formControls col-xs-8 col-sm-9"> <input type="number" step="0.01" class="input-text" value="${priceChange.activity_gap}" placeholder="" id="activity_gap" name="activity_gap" > 元/L </p> </p> </p>
Then the implementation in jquery
jQuery(document).ready(function($) { //是否添加活动内容 $("#isHaveActive").change(function(){ var p = $("#active"); p.css("display") === "none" && p.show() || p.hide(); });
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
How to implement click on DIV to trigger click on CheckBox in jQuery
How to change the background color of click state in AngularJs
Bootstrap grid system (detailed tutorial)
How to use prop-types in React Native to implement attribute confirmation
The above is the detailed content of How to use JS to modify the display state by clicking on the checkbox. For more information, please follow other related articles on the PHP Chinese website!