JS实现点击复选框变更DIV显示状态的示例代码 程序员文章站 2022-03-16 16:48:04 首先是页面上: 首先是页面上: <div class="row cl"> <label class="form-label col-xs-4 col-sm-3" style="width: 20%"><span class="c-red">*</span>是否存在促销活动:</label> <div class="formcontrols col-xs-8 col-sm-9 skin-minimal"> <div class="check-box"> <input type="checkbox" value="1" id="ishaveactive" > <label for="ishaveactive"> </label> </div> </div> </div> <div id="active" name="active" style="display:none;"> <div class="row cl" > <label class="form-label col-xs-4 col-sm-3" style="width: 20%"><span class="c-red">*</span>现价:</label> <div 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 </div> </div> <div class="row cl" > <label class="form-label col-xs-4 col-sm-3" style="width: 20%"><span class="c-red">*</span>活动名:</label> <div 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" > </div> </div> <div class="row cl" > <label class="form-label col-xs-4 col-sm-3" style="width: 20%"><span class="c-red">*</span>距挂牌价:</label> <div 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 </div> </div> <div class="row cl" > <label class="form-label col-xs-4 col-sm-3" style="width: 20%"><span class="c-red">*</span>促销活动形式:</label> <div 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" > </div> </div> <div class="row cl" > <label class="form-label col-xs-4 col-sm-3" style="width: 20%"><span class="c-red">*</span>促销活动优惠幅度:</label> <div 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 </div> </div> </div> 然后是jquery中的实现 jquery(document).ready(function($) { //是否添加活动内容 $("#ishaveactive").change(function(){ var div = $("#active"); div.css("display") === "none" && div.show() || div.hide(); }); 以上这篇js实现点击复选框变更div显示状态的示例代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。 上一篇: css---animation属性[email protected]属性添加动画 下一篇: Flash CS5怎么精确调整图形的位置? 推荐阅读 JS实现点击复选框变更DIV显示状态的示例代码 JS点击复选框变更p显示状态的示例代码 JS点击复选框变更p显示状态的示例代码 JS实现点击复选框变更DIV显示状态的示例代码