Uncaught ReferenceError: myFunction is not defined

前端 未结 4 694
长发绾君心
长发绾君心 2020-12-06 19:36

Gives an error. I have placed the code just before . Still getting the error.

4条回答
  •  我在风中等你
    2020-12-06 20:09

    From the jQuery docs:

    The handler passed to .ready() is guaranteed to be executed after the DOM is ready, so this is usually the best place to attach all other event handlers and run other jQuery code.

    So your function isn't created until after your onclick is established. Thus it can't find the function. You'll want to move it outside the $(document).ready(function(){}).

提交回复
热议问题