onChange function is not defined

前端 未结 5 969
醉酒成梦
醉酒成梦 2020-12-20 11:25

This has got to be something simple. I searched the internet and only found syntax errors as the cause of this problem, but I can\'t find a syntax error.

Here\'s the

5条回答
  •  余生分开走
    2020-12-20 12:15

    The hi function is only in scope inside the ready event handler. Move it outside of the event handler, or handle the binding inside there (and remove the inline event handler attribute from the markup):

    $(document).ready(function(){
        function hi(){
            alert('hi');
        }
        $("#cep").on("change", hi);
    });
    

提交回复
热议问题