Code only works on jsfiddle

不羁的心 提交于 2019-12-02 03:28:00

you missed http: in the jQuery source link. if you using online resource you should follow the url's protocol. Other wise browser will search it from local. in this way you just confused your browser... So only it happens... :D

you should use...

<script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.js'></script>

instead of

<script type='text/javascript' src='//code.jquery.com/jquery-1.9.1.js'></script>

As per snapshot, You are using

<script type='text/javascript' src='//code.jquery.com/jquery-1.9.1.js'></script>

Replace it with

<script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.js'></script>

You are using protocol less Urls, i.e. //code.jquery.com/jquery-1.9.1.js, When you open a your html file like file:// then jQuery is not loaded thus desired result is not achieved.

However, if you test your html file like http://localhost/yourfile.html you will get the desired result.

Note: Use // instead of http:// when you want to inherit the protocol from the page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!