Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用jquery将变量传递到引导确认模式按钮_Javascript_Php_Jquery_Twitter Bootstrap - Fatal编程技术网

Javascript 如何使用jquery将变量传递到引导确认模式按钮

Javascript 如何使用jquery将变量传递到引导确认模式按钮,javascript,php,jquery,twitter-bootstrap,Javascript,Php,Jquery,Twitter Bootstrap,我想将一个处理程序附加到单击删除按钮上的事件,这将弹出一个确认模式。 确认后,它应该重定向到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"

我想将一个处理程序附加到
单击删除按钮上的
事件,这将弹出一个确认模式。
确认后,它应该重定向到
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>
删除

然后使用jQuery利用jQuery中的
$cid
值,
标记属性
选择器用于在具有属性
数据cid
的按钮上定位单击事件。在定位click事件之后,使用
$(this)
定位单击的当前元素以检索属性
.attr('data-cid')
value

我希望我可以标记一个问题两次。你的问题已经被问到了:可能的重复
$("button[data-cid!='']").click(function() {
    var getCid = $(this).attr("data-cid"); // this returns $cid
    //your statements what you wanna proceed with
});
$("button[data-cid!='']").click(function() {
    var getCid = $(this).attr("data-cid"); // this returns $cid
    //your statements what you wanna proceed with
});