调用的html代码:
<a class="bk-round bk-border-info bk-border-darken bk-bg-lighten bk-border-3x bk-icon bk-icon-default bk-bg-info" data-toggle="modal" data-target="#myModal" data-placement="top" title="" data-original-title="View"> <i class="fa fa-mail-forward"></i> </a> </td>
根据如下的方法可以获取Bootstrap3 Modal的调用元素
$('#myModal').on('show.bs.modal', function (e) {
var invoker = $(e.relatedTarget);
alert(invoker.html()); }
);
通过e.relatedTarget可以拿到调用model的html元素标签,通过invokrer可以根据该元素的属性名来拿到属性的值:
比如通过invoker.
modal模板如下:
<!-- Modal --> <div id="myModal" class="modal fade" tabindex="-1"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"><button class="close" type="button" data-dismiss="modal">×</button> <h4 id="myModalLabel" class="modal-title">Modal title</h4> </div> <div class="modal-body">...</div> <div class="modal-footer"><button class="btn btn-default" type="button" data-dismiss="modal">Close</button> <button class="btn btn-primary" type="button">Save changes</button></div> </div> <!-- /.modal-content --></div> <!-- /.modal-dialog --></div> <!-- /.modal -->