Home  >  Article  >  Web Front-end  >  jQuery exercises [1] Preparations for learning jquery_jquery

jQuery exercises [1] Preparations for learning jquery_jquery

WBOY
WBOYOriginal
2016-05-16 18:26:181073browse

Using jQuery to write JavaScript scripts is like using Delphi to write Windows programs. It is not more powerful, but easier to use.

I plan to comprehensively browse and test the syntax of jQuery first, and gain insight into its logic and ideas; finally try Using jQuery in Delphi is probably much more convenient than using MSHTML.pas.

Official site: http://jquery.com/
Chinese document: http ://jquery-api-zh-cn.googlecode.com/
Download address: http://docs.jquery.com/Downloading_jQuery

jQuery library is A js file has versions with different specifications:

To view the source code, you should use: standard version (such as: jquery-1.4.2.js)
In actual applications, you should use: min version (such as: jquery- 1.4.2.min.js);
You can use the vsdoc version with code prompts when editing in VS, but the latest version of vsdoc that can be found is 1.4.1, which is also acceptable.

PS: The following running code is added with jquery. After running, refresh it and you can see the effect.

should be called in the page before use; test page:


[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute it
]
The jQuery code should be written in Where? This is no different from ordinary JavaScript, such as the following code: ...
[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
]

...


[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
...




[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
...
[Ctrl A select all Note: <script> //完整的写法 jQuery(document).ready(function() { alert("Hello"); }); //jQuery 可简写为 $ $(document).ready(function() { alert("Hello"); }); //$(document) 可以简写为 $() $().ready(function() { alert("Hello"); }); //$(document).ready() 也可以简写为 $() $(function() { alert("Hello"); }); </script>If you need to introduce external Js, you need to refresh to execute ]<script> $(function() { alert("Hello jQuery 1") }); window.onload = function() { alert("Hello JavaScript 1") }; //这会被覆盖 window.onload = function() { alert("Hello JavaScript 2") }; $(function() { alert("Hello jQuery 2") }); </script>
window.onload() 发生在页面载入完成时,
$(document).ready() 发生在页面主体框架载入完成时(或许某个图片还没下载完);
当需要这个时机时, 我更喜欢把代码放在页尾:

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]


用什么工具呢? 听说有很多, 我觉得 VS 就不错, 还有代码提示, 就是太慢了, 不如自己写一个:
jQuery exercises [1] Preparations for learning jquery_jquery

JavaScriptTest2.rar
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn