此時,只有當用戶點擊鏈接下面的代碼將加載。的Onload點擊鏈接
我想在頁面加載時發生這種情況,而無需用戶點擊。
<script>
$(document).ready(function() {
// Support for AJAX loaded modal window
$(document).on('click', '.btn-modal', function() {
$.get($(this).attr('data-target'), function(data) {
$('#modal').html(data);
$('#modal').modal('show');
}, 'html');
});
});
</script>
<!-- Modal window to load dynamic content -->
<div class="modal hide fade customDialog" id="modal"></div>
<a class="btn btn-modal" data-target="page.html" >Launch Modal</a>
可能重複(http://stackoverflow.com/questions/6158532/jQuery的如何:觸發點擊) –