当我点击拒绝按钮
时我正在呼叫/触发下一个按钮点击事件。
是否可以通过调用reject ??
从下一个事件函数中知道请求是否已经到来这是我的傻瓜 http://jsfiddle.net/6xskkzjh/9/
这是我的代码
<input type="button" id="next" value="Next">
<input type="button" id="prev" value="Prev">
<div id="countdiv">
<Span>Showing </Span> Of <span>Items</span>
</div>
<input type="button" value="Reject One Item" id ="reject">
var totalcount = 10;
var current_count = 0;
$(document).on('click', '#prev', function (event) {
if (current_count > 1) {
current_count--;
updateDiv();
}
});
$(document).on('click', '#next', function (event) {
if (current_count < totalcount) {
current_count++;
updateDiv();
}
});
function updateDiv() {
$('#countdiv').html('Showing ' + current_count + ' of' + totalcount + ' items');
}
$(document).on('click', '#reject', function (event) {
totalcount--;
$("#next").click();
});
答案 0 :(得分:2)
如果未定义,则可以检查 originalEvent ,然后通过触发器检查 {/ 3>}
$(document).on('click', '#next', function (event) {
if(event.originalEvent=== undefined){
//triggered....not clicked
}
if (current_count < totalcount) {
current_count++;
updateDiv();
}
});
<强> Working Demo 强>