sorry, stupid question here. if post question javascript or jquery, people - create jsfiddle.
so, did. question getting divs slide using jquery but, can't basic javascript function run in jsfiddle.
<div onclick="showit()">hello</div> function showit() { alert('hi'); }
a div, click on call javascript function, jsfiddle says function not defined. can not in jsfiddle?
you've selected default onload
option in jsfiddle.
this causes site wrap entire code within callback function, meaning showit
function not global function required dom0 inline event handlers.
there several work arounds, in personal order of preference:
don't use dom0 inline handlers, they're really old school -
element.addeventlistener()
instead , separate markup js.use
window.showit = function() { ... }
instead force function appear in global name space.select 1 of "no wrap" options
Comments
Post a Comment