时间:2020-12-02 13:25:56 | 栏目:JavaScript代码 | 点击:次
如下所示:
前端代码
<link rel="stylesheet" href="/static/index/layui/css/layui.css" rel="external nofollow" > <script type="text/javascript" src="/static/index/layui/layui.js" charset="utf-8"></script> <script type="text/javascript" src="/static/index/js/jquery-3.3.1.min.js" charset="utf-8"></script> <form class="layui-form" action=""> <div class="layui-form-item"> <label class="layui-form-label" style="width:100px">是否已购买:</label> <div class="layui-input-block" id="IsPurchased" > <input type="radio" name="t" value="购买" title="购买" lay-filter="aaa"/> <input type="radio" name="t" value="试用" title="试用" lay-filter="aaa"/> </div> </div> <div class="layui-form-item count"> <label class="layui-form-label">试用次数:</label> <div class="layui-input-inline"> <input type="text" id="ProbationAccount" required="required" placeholder="请输入试用次数" autocomplete="off" class="layui-input" /> </div> <div class="layui-form-mid layui-word-aux"></div> </div> </form> <script> layui.use('form', function () { var form = layui.form; form.on('radio(aaa)', function (data) { if ($('#IsPurchased input[name="t"]:checked ').val() == "购买") { $(".count").hide(); } else { $(".count").show(); } form.render(); }); }); </script>