想通過onclick='test'調用函數,發現如下問題,求證。場景一:可以正常執行<script>$(function($){ function test(){ console.log('123');
}
});</script><button onclick='test()' >adadas</button>場景二:test:34 Uncaught ReferenceError: test is not defined<button onclick='test()' >adadas</button><script>$(function($){ function test(){ console.log('123');
}
});</script>問題:如果想用onclick='test()',只能 先把 函數寫在 需要調用的元素之前嗎?
內聯js onclick 函數順序問題
尚方寶劍之說
2018-09-13 14:30:27