2008-11-19 35 views

Trả lời

9

bạn đã xem xét plugin hasEvent() chưa? mã là khá nhỏ:

(function(A) { 
    A.fn.hasEvent = function(C) { 
     var B = this.data("events"); 
     return(B && B[C]) 
    } 
}) (jQuery) 

cho mục đích cụ thể của bạn, bạn có thể sửa đổi nó một chút:

(function($) { 
    $.fn.hasEvents = function() { 
     return new Boolean(this.data('events')); 
    } 
}) (jQuery); 

$('#someDiv').click(function() { 
    alert('new event'); 
}); 

$('#someDiv').hasEvents();  // true 
$('#someOtherDiv').hasEvents(); // false 
Các vấn đề liên quan