如何使用 jquery 将变量传递给引导确认模式按钮
How to pass variables to bootstrap confirm modal button use jquery
我想在"删除"按钮上将处理程序附加到click
事件,这将弹出一个确认模式。确认后,应重定向至process.php?cid=$cid
。但是如何将变量$cid
传递给模式删除呢?
数据列表:
<?php
foreach($getChannel as $data) {
?>
<div class="btn-group btn-group-solid">
<a class="btn red" data-toggle="modal" href="#small" id="<?php echo $cid?>">
<i class="fa fa-trash"></i> Delete </a>
</div>
<?php
}
?>
模 态:
<div class="modal fade bs-modal-sm" id="small" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h4 class="modal-title">Confirm</h4>
</div>
<div class="modal-body">
Are you sure to delete?
</div>
<div class="modal-footer">
<button type="button" class="btn green" data-dismiss="modal" id="delcancel">cancel</button>
<button type="button" class="btn red" id="del" onclick="process.php?cid=$cid">Go Delete</button>
</div>
</div>
</div>
</div>
如何使用 jQuery 接收$cid变量?
<button type="button" class="btn red" id="del" onclick="process.php?cid=$cid">Go Delete</button>
<button type="button" class="btn red" id="del" data-cid="<?php echo $cid; ?>">Go Delete</button>
使用保存$cid
值的自定义属性
$("button[data-cid!='']").click(function() {
var getCid = $(this).attr("data-cid"); // this returns $cid
//your statements what you wanna proceed with
});
然后使用 jQuery 在 jQuery 中利用您的$cid
值,tag with attribute
选择器用于将点击事件定位到具有属性data-cid
的按钮上。 定位点击事件后,用于$(this)
定位单击的当前元素以检索属性.attr('data-cid')
值
相关文章:
- 弹出格式化的模式对话框,并在用户确认时转发
- 模式警报,但确认按钮未对脚本做出反应
- 确认删除的模式对话框
- Bootstrap3确认模式回调触发两次
- 使用弹出模式中断k-pager-nav以确认/拒绝移动到新页面
- 确认脏表单上的角度模式关闭
- 如何使用 jquery 将变量传递给引导确认模式按钮
- 简单模态 - 如何将电子邮件地址传递给确认模式
- 引导模式确认
- jQuery UI 模式确认对话框,ASP.NET 不会在单击事件中触发
- 用户不会显示 JQuery 模式对话框确认
- 在引导确认模式下控制确认按钮
- 确认模式按钮 asp.net 的操作
- Bootstrap 3:添加确认模式框jQuery内联删除行
- 简单确认模式/弹出式-MVC 5/Bootstrap 3
- 在AngularJs中调用$routeChangeStart之前显示确认模式,比如window onbeforeunlo
- 在确认模式和提交表单之前验证表单字段
- 为什么这些确认模式没有出现
- 使用Bootstrap和AJAX删除确认模式
- 在表单数据中,传递关于单击哪个按钮的信息——在确认模式之后