开发者

Checking jQuery event types

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜