开发者

Checking jQuery event types

开发者 https://www.devze.com 2023-04-12 21:07 出处:网络
Let\'s say, jQuery has scroll event type. Is there a chance to det开发者_运维技巧ermine whether it\'s assigned an event handler?Yes.You can.

Let's say, jQuery has scroll event type. Is there a chance to det开发者_运维技巧ermine whether it's assigned an event handler?


Yes.You can.

<input id="fname" type="text"  name="fname" />


$('#fname').change(function(){ alert('change!' );})

if (($.data( $('#fname').get(0), 'events' ).change).length>0)
{
    alert('You have "change" event handler assigned.');
}

Demo


You can use event.type to check the event type.

http://api.jquery.com/event.type/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号