The factory function of jquery Foundation and the classic example analysis of timer _jquery

Source: Internet
Author: User
Tags current time setinterval jquery library

1. Basic information on jquery:

1.1 Definition: jquery is one of the JavaScript libraries, it is the encapsulation of JavaScript objects and utility functions,

1.2 Effects: Many interactive effects that can be implemented using JavaScript, which are perfectly implemented using jquery, are understood by five purposes.

1.2.1 Access and manipulation of DOM elements

1.2.2 Make page style

1.2.3 The processing of page time

1.2.4 Easy to use the jquery plugin

The perfect combination of 1.2.5 and Ajax

1.3 Advantage: Someone would ask: why do people choose jquery more? Because the gist of jquery is Wrute less,do more (with less code, more functionality),

It has unique selectors, chain operations, event-handling mechanisms and encapsulation, and perfect Ajax are all other JavaScript crying.

2.jQuery Related applications:

2.1 If you want to refer to the jquery library in the page, just place the downloaded jquery library in the directory JS, and use the relative path for general reference. jquery's keyword "$"

2.2 Syntax and cases of related functions

The function module that 2.2.1 waits for the HTML page to parse after all documents are finished

$ (document). Ready (function () {
   
    alert (message);//function, event module

  });


Abbreviated version

$ (function () {

   alert (message);//function, event module

});

2.2.2 Factory function $ ()

$ () Action 1: Converts a DOM object into a jquery object, because the jquery method can be used only after the DOM object has been converted to a jquery object (the jquery method is unique)

$ (function () {
      //convert jquery to DOM object
      var dom = $ ("#mli") [0];
      You can then call the DOM's property
      Dom.innertext;
      Converts a DOM object to a jquery object
      var $dom = $ (DOM);
      The method of calling its Jquerry with a jquery object
      $dom. Text ();

$ () Effect 2: Registers events by obtaining the selector name and then giving the selector the corresponding content

The mouse moves over the label and removes the two event
//jquery unique consonant effect
  $ (function () {
      $ ("Li"). MouseOver (function () {      
        $ (this). CSS (" Background "," green ");
      Mouseout (function () {
        //this.style.background = "";
        This.style.cssText = "background:"

;}); Click event

 $ (function () {
      $ ("H2"). Click (function () {
        $ ("H2"). CSS ({"font-size": "50px", "Color": "Red"});
        $ ("P"). css ({"font-size": "30px", "Color": "Red", "Padding-left": "1px", "Line-height": "30px"});}
    );

3. Several classic cases of timer

3.1 Picture Auto Switch

 
 

3.2 Countdown (can start, stop, continue)

 

3.3 Get the current time and start the timer run

//in front of the number less than 10 with a 0
    function checktime (i) {
      if (I <)
      {i = "0" + i} return
      i
    }
  </ script>
 
 

Above the jquery base of the factory function and timer of the classic example analysis is small series to share all the content, hope to give you a reference, but also hope that we support cloud habitat community.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.