Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  7] [ 7]  / answers: 1 / hits: 37876  / 15 Years ago, mon, december 7, 2009, 12:00:00

I found the way to check if event exists on element. But it's not work on the events which is not delegated by jQuery:


When I try,


$("a").data("events");

for this.


<a href="#" onClick="alert('Hello, World!')" />

It returned undefined.


Is there any way to check if onClick exists on elements with jQuery?


More From » jquery

 Answers
6

You can do:



if ($('a').attr(onClick) != undefined) {}

[#98132] Thursday, December 3, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
devinjadong

Total Points: 711
Total Questions: 117
Total Answers: 100

Location: Andorra
Member since Sat, May 27, 2023
1 Year ago
devinjadong questions
Thu, Feb 17, 22, 00:00, 2 Years ago
Wed, Dec 8, 21, 00:00, 2 Years ago
Tue, Oct 27, 20, 00:00, 4 Years ago
Fri, Oct 18, 19, 00:00, 5 Years ago
;