html - JavaScript onclick event for button/function elemtn_onclick() difference -
i have question difference between following code. method more preferable? why? pro's/con's?
more of better question: other events there other onclick? on change events?
method 1
htmlid.onclick = function () { alert("whatever"); }
method 2
function htmlid_onclick() { alert("whatever"); }
the reason why i"m curious method # 1 didn't work double-clicked button in visual studio , added function automatically worked. why things manual way when automatic?
method #2 better way of writing functions, should try write manually, visual studios. can add odd code or misinterpret issue or put in wrong variables , stuff , you're left issue , no idea how fix it.
Comments
Post a Comment