In jQuery when I add onclick attribute for an element it doesn't add this attribute, but it works. So how does it works?
An onclick handler like jQuery
Collapse
X
-
Thanks Dormilich
But if you had Firebug installed on Firefox you can see ondemand edits in page source. (by using Inspect Element)
if you run this code it will add in source coder:
But when i use jQuery it doesn't add anything to page souce.Code:document.getElementById("my_element").onclick = 'function(){ alert("Hello!"); }';Comment
-
the standard way to create event handlers:
Code:elem.addEventListener("event", callback, capture); // elem - the HTML element concerned // event - event type (e.g. "click") // callback - the name of the function to execute // capture - boolean indicating whether to fire in capturing or bubbling phaseComment
Comment