我想知道如何以最简单的方式(因为我是。我的知识是HTML,Bootstrap和基本CSS的基础),我可以做到以下几点:
'如果单击单选按钮#1,单击单选按钮#4,单击正常按钮#2,然后单击提交:在页面的第x部分中显示模式(内部图片)1
'如果单击单选按钮#1,单击单选按钮#2,单击正常按钮#7,然后单击提交:显示模式(内部图片)23页面的第x部分
我觉得这应该可以通过Bootstrap实现,但我现在无法理解它。有人能指出我正确的方向吗?
答案 0 :(得分:0)
取自Bootstrap模态documentation本身:
有一堆按钮都会轻微触发相同的模态 不同的内容?使用event.relatedTarget和HTML data- *属性 (可能通过jQuery)根据情况改变模态的内容 单击了哪个按钮。
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@mdo">Open modal for @mdo</button>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@fat">Open modal for @fat</button>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@getbootstrap">Open modal for @getbootstrap</button>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">New message</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="recipient-name" class="col-form-label">Recipient:</label>
<input type="text" class="form-control" id="recipient-name">
</div>
<div class="form-group">
<label for="message-text" class="col-form-label">Message:</label>
<textarea class="form-control" id="message-text"></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Send message</button>
</div>
</div>
</div>
</div>
$('#exampleModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget) // Button that triggered the modal
var recipient = button.data('whatever') // Extract info from data-* attributes
// If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
// Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead.
var modal = $(this)
modal.find('.modal-title').text('New message to ' + recipient)
modal.find('.modal-body input').val(recipient)
})
鉴于我们并不具体了解您要加载的内容,您应该修改它以满足您的需求。