Just a note: click is an event. onclick is a handler.
–
Alin PurcaruDec 11 '10 at 11:19

1

@Alin: onclick is an attribute, and also a property (the property reflects the attribute); what you assign to it is a handler.
–
T.J. CrowderDec 11 '10 at 11:22

@Alin @T.J. Crowder onclick is neither attribute nor handler. It is a variable which when interpreted in the context of an element object is an attribute that points to a handler.
–
Box9Dec 11 '10 at 11:29

@T.J. Crowder What you said is just like saying that if you have var fn = function(){};, then fn is not a function.
–
Alin PurcaruDec 11 '10 at 11:30

@box9: "onclick is neither attribute nor..." That's kind of going to come as a surprise to the W3C: w3.org/TR/html5/webappapis.html#handler-onclick It says they "...must be supported by all HTML elements, as both content attributes and IDL attributes..." (an "IDL attribute" being what we commonly call a "reflected property": w3.org/TR/html5/…).
–
T.J. CrowderDec 11 '10 at 11:37

i tried the get method but it returns null every time for some reason. i am checking to see if i am calling it wrong. the source and title works so im not sure what i am doing wrong.
–
iTEggDec 11 '10 at 11:19

@iEisenhower - IS there an onclick value? If not it'll return undefined.
–
Box9Dec 11 '10 at 11:23

i will think this through and then give my response. i think all of you have given me enough clues to help me investigate this issue. thanks.
–
iTEggDec 11 '10 at 11:25

It's important to remember what onclick actually is: It's an attribute (and a reflected property) that can be used to attach a handler to the click event using the old, "DOM0" (e.g., never-standardized) mechanism.

If you are attaching a click handler using a standardized mechanism like addEventListener or IE's near-equivalent attachEvent, onclick will remain null or undefined because those are not assigned to the onclick attribute or property.

+1. You say onclick will remain null though. Will it be set to null or will it "remain" undefined?
–
Box9Dec 11 '10 at 11:33

@box9: It depends on the browser. (I just added undefined, because I saw that in the Firefox results.) The default value of the property seems to be null on most browsers.
–
T.J. CrowderDec 11 '10 at 11:34