-1

I need to determine if a jQuery object has the jQuery .click() event, if not I need to use the JavaScript one: $("#Call")[0].click()

Basically I need a way to this (this is pseudo code):

if ($("Call").click() == valid){
    $("Call").click()
} else {
    $("Call")[0].click()
}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
ism
  • 288
  • 1
  • 5
  • 17
  • 1
    Why would you be able to use jquery but not jquery click event? – juvian Oct 09 '14 at 19:55
  • 1
    `$("#foo").click && $("#foo").click() || $("#foo")[0].click()` however, that makes absolutely no sense. a jQuery object should always have a click property pointing to a function that triggers a click event. – Kevin B Oct 09 '14 at 19:57
  • http://stackoverflow.com/questions/2008592/can-i-find-events-bound-on-an-element-with-jquery – epascarello Oct 09 '14 at 20:07
  • @KevinB I know it doesn't make sense... but it appears as though that is the case – ism Oct 09 '14 at 20:34
  • @KevinB $("#Call").click returns "function (e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)} " but when I call .Click() it doesn't do anything... it doesn't open the page when I .click the link – ism Oct 09 '14 at 20:36
  • click and Click are two different things. was that a typo? – Kevin B Oct 09 '14 at 20:45
  • @KevinB What's the difference? – ism Oct 09 '14 at 20:47
  • `a.b = 5; alert(a.B); // undefined` – Kevin B Oct 09 '14 at 21:35

1 Answers1

-1

Not sure why you would need to do it, but to answer your question would mean you need to look up where jQuery stores it's events. if there is an event for that type, there will be an array, if there is no event, than it is undefined.

var evtData = $._data($("#Call").get(0)).events;
var hasClickAttached = evtData  && evtData.click !== undefined;
epascarello
  • 204,599
  • 20
  • 195
  • 236