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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -