获取被触发的事件的名称(类型) [英] Get the name (type) of the event that was fired (triggered)
本文介绍了获取被触发的事件的名称(类型)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码:
$('#my-button').on('click change', function(event) {
alert("Who fired me, click or change?");
});
我如何知道被调用的事件是点击还是更改?
How can I know if the event called was "click" or "change"?
推荐答案
event.type
会让你想要的。
另请参见:
事件类型列表
$("#tipo-imovel").on("click change", function(event){
console.log(event.type + " is fired");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<input type="text" id="tipo-imovel" />
这篇关于获取被触发的事件的名称(类型)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文