且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将值参数传递给 Bootstrap 中的 modal.show() 函数

更新时间:2023-11-26 18:17:16

你可以这样做:

<a class="btn btn-primary announce" data-toggle="modal" data-id="107" >Announce</a>

然后使用jQuery绑定点击并发送Announce data-id作为modals中的值#cafeId:

Then use jQuery to bind the click and send the Announce data-id as the value in the modals #cafeId:

$(document).ready(function(){
   $(".announce").click(function(){ // Click to only happen on announce links
     $("#cafeId").val($(this).data('id'));
     $('#createFormId').modal('show');
   });
});