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/
精彩评论