摘要:[jQuery]使用jQuery時,出現is not defined錯誤訊息
最近在使用jQuery的時候,自己竟然傻傻的沒把jQuery的核心檔放入
而也未出現任何錯誤訊息,用Chrome F12 開啟Web developer tool的界面後,重整F5
要是有問題,在Sources處會出現以下圖示:
出現is not defined錯誤訊息,在拜Google大神所賜,找到了問題的癥結點:http://stackoverflow.com/questions/2194992/jquery-is-not-defined
在最佳解答地方有提到三點:
That error can only be caused by one of three things:
1.Your JavaScript file is not being properly loaded into your page
2.You have a botched version of jQuery. This could happen because someone edited the core file, or a plugin may have overwritten the $ variable.
3.You have JavaScript running before the page is fully loaded, and as such, before jQuery is fully loaded.
這次出現的錯誤,在加入CDN後就可順利執行jQuery了
個人較常到這邊尋找要用到的CDN,Google Hosted Libraries:https://developers.google.com/speed/libraries/?csw=1