function loadToFalloutPopup() {
$('#fallout-all-modal').modal({
backdrop: true,
keyboard: true
});
}
$document.on('click', '.all-fallout-btn', loadToFalloutPopup)
});
HTML:
<button type="button" class="all-fallout-btn" data-dismiss="modal">To Fallout</button>
第二次点击时会触发JQuery点击事件,但不会在第一次点击时触发。我不知道锣是什么,请帮忙。
答案 0 :(得分:0)
试试这个:
function loadToFalloutPopup() {
$('#fallout-all-modal').modal({
backdrop: true,
keyboard: true
});
}
$(document).ready(function() { // always write any event on $(document).ready
$(document).on('click', '.all-fallout-btn', function() { // use click event like this
loadToFalloutPopup();
});
})
答案 1 :(得分:0)
试试这个
$(document).on('click', '.all-fallout-btn', function(){
loadToFalloutPopup()
});
var count=0
function loadToFalloutPopup() {
count++
$('#spanCount').text(count);
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button type="button" class="all-fallout-btn" data-dismiss="modal">To Fallout</button><br/><span id='spanCount'>0</span>
&#13;