JQuery entry-progress bar, jquery entry
More and more people feel that regular javascript cannot keep up with the pace, and they plan to learn more advanced, starting with JQuery.
JQuery is a Javascript library that can be downloaded from JQuery.com and stored locally.
<Script src = "jquery. js"> </script>
Statement. If you do not want to download jquery, You can reference the jquery library on the web and reference their jquery library from google or Microsoft servers.
Reference google's jquery Library:
<Script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"> </script>
Reference Microsoft's jquery Library:
<Script src = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"> </script>
We recommend that you reference google or Microsoft's jquery library. Many users have loaded jQuery from Google or Microsoft when visiting other sites. The result is that jQuery is loaded from the cache when they access your site, which can reduce the loading time. At the same time, most cdns can ensure that when users request files from them, they will return a response from the server closest to the user, which can also increase the loading speed.
All JQuery functions are located in a document ready function.
$ (Document). ready (function (){
--- JQuery functions go here ----
});
This is to prevent the document from running jQuery code before it is fully loaded (ready. If you run the function before the document is fully loaded, the operation may fail.
The Jquery selector will not be mentioned. The two points to be noted are all over. The following shows an example. I re-wrote the progress bar written in conventional javascript with jquery. Although the knowledge points used are very simple, however, writing it out also takes me a bit of thought, because some things are still different from conventional javascript, which is put behind the code. The complete code of the progress bar is as follows.
<! Doctype html>
This time it mainly took some time to increase the score by, because the setTimeout () function is used. In jquery, setTimeout (code, delay) if the code in it is a function, you only need to fill in the function name, no quotation marks, no parentheses. For example, if you have a function show () and call show () after setting ms, you should write in jquery as follows:
SetTimeout (show, 500 );
In traditional javascript, you need to write as follows:
SetTimeout ("show ()", 500 );
This is also true for setInterval.