javascript - Inline event handler not working in JSFiddle -
javascript - Inline event handler not working in JSFiddle -
i can't find out problem jsfiddle.
html:
<input type="button" value="test" onclick="test()">
javascript:
function test(){alert("test");}
and when click on button - nil happened. console says "test not defined"
i've read jsfiddle documentation - there written, js code added <head>
, html code added <body>
. (so js code before html , should work)
the function beingness defined within load handler , in different scope. @ellisbben notes in comments, can prepare explicitly defining on window
object. better, yet, alter apply handler object unobtrusively: http://jsfiddle.net/pueue/
$('input[type=button]').click( function() { alert("test"); });
note applying handler way, instead of inline, keeps html clean. i'm using jquery, or without framework or using different framework, if like.
javascript html jsfiddle
Comments
Post a Comment