0
最終我試圖讓標題和作者在圖像下方顯示。試着讓引導模式輪播標題出現
下面是HTML:
<div class="row">
<div class="col-lg-3 col-sm-4 col-6"><a href="#" title="Image 1" data-caption="This is a caption."><img src="//placehold.it/600x350" class="thumbnail img-responsive"></a></div>
<div class="col-lg-3 col-sm-4 col-6"><a href="#" title="Image 2" data-caption="This is a caption."><img src="//placehold.it/600x350/2255EE" class="thumbnail img-responsive"></a></div>
</div>
<div id="myModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 class="modal-title">Heading</h3>
</div>
<div class="modal-body">
<p class="modal-caption"></p>
</div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
和JavaScript。我只是不知道自己做錯了什麼,所以任何幫助都會很棒。我試圖訪問錨標籤內的數據屬性來填充相應的div(數據標題將顯示在。)。
// Gallery Modal
$('.thumbnail').click(function(){
$('.modal-body').empty();
var title = $(this).parent('a').attr("title");
$('.modal-title').html(title);
var caption = $(this).parent('a').attr("data-caption");
$('.modal-caption').html(caption);
item.attr("data-caption",caption);
item.appendTo('.modal-caption');
$($(this).parents('div').html()).appendTo('.modal-body');
$('#myModal').modal({show:true});
});
你是上帝的好先生。非常感謝你。 – zach57