javascript - javascript函数禁用div中的变量发送,如何停止
问题描述
$('[data-toggle="wizard-radio"]').click(function() {
wizard = $(this).closest('.wizard-card');
wizard.find('[data-toggle="wizard-radio"]').removeClass('active');
$(this).addClass('active');
$(wizard).find('[type="checkbox"]').removeAttr('checked');
$(this).find('[type="checkbox"]').attr('checked','true');
})
此代码以某种方式禁止发送变量,因此我可以$_POST
在服务器端使用数组获取它
任何想法如何在提交时激活它以发送
解决方案
这两条线需要帮助
$(wizard).find('[type="checkbox"]').removeAttr('checked');
$(this).find('[type="checkbox"]').attr('checked','true');
复选框的正确方法是.prop('checked', true/false)
我还删除了该hidden
属性,因为它使事物不可见。你需要那个吗?
$('[data-toggle="wizard-radio"]').click(function() {
wizard = $(this).closest('.wizard-card');
wizard.find('[data-toggle="wizard-radio"]').removeClass('active');
$(this).addClass('active');
$(wizard).find('[type="checkbox"]').prop('checked', false);
$(this).find('[type="checkbox"]').prop('checked', true);
})
.active {
color: #f00;
}
.card-checkboxes {
display: inline-block;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class='wizard-card'>
<div class="choice" data-toggle="wizard-radio">
<div class=" btn-next " hidden>
<input type="checkbox" name="Great" value="Great">
<div class="card card-checkboxes card-hover-effect">
<i class="ti-face-smile"></i>
<p style="font-weight: bold;">Great</p>
</div>
</div>
</div>
<div class="choice" data-toggle="wizard-radio">
<div class=" btn-next ">
<input type="checkbox" name="soso" value="Soso">
<div class="card card-checkboxes card-hover-effect">
<i class="ti-face-smile"></i>
<p style="font-weight: bold;">So-so</p>
</div>
</div>
</div>
</div>
推荐阅读
- sql-server - 在 SQL Server Management Studio 中恢复未保存的 SQL 查询脚本
- ios - 添加 AllInOneSDKSwiftWrapper.swift 后,如何在一个 sdk 中实现 Paytm all in react native 给出错误
- python - Scrapinghub (Scrapy Cloud) - 每个项目的蜘蛛数量有限制吗?
- mapbox-gl-js - 在 Mapbox GL 中有一种方法可以让符号的标签成为自定义 HTML
- web - heroku 托管是如何构建的?它如何支持这么多语言的项目来托管它?
- r - 优化错误(par = par,fn = fun,method = "L-BFGS-B",lower = lb,upper = ub):L-BFGS-B 需要 'fn' 的有限值
- mongodb - Logstash 无法加载,文件不可读
- android - Android ROOM - 如何在对象内插入对象(即 Flash Card Deck 有一个问题列表)
- flutter - Flutter 中的动态自定义日历
- reactjs - KendoReact 网格复选框过滤器