jquery First Experience (recommended learning jquery) _jquery

Source: Internet
Author: User
Tags version control system
In jquery's web siteFound that this dongdong provides two versions of the download. One is the original, close to 120K, the other is to compress the water, nearly 60K. Too long did not do the application technology, unexpectedly came out so many new things, JavaScript can also compress moisture, so by the way again to understand a bit The packer of JavaScript(This is an online link), if interested, hereYou can download several versions of its. NET, Perl, WSH, and PHP.

Don't pull it off, talk back to the point. The compressed version of jquery is the right network to speed up, but the compressed jquery only a row, not suitable for the VCS (version control system) management. Therefore, the first use of the uncompressed version of the release of the product later when the compression is good.

On SVN to create a good project, wrote a readme up, because it involves the configuration of things, with plain text is not convenient to read, so use HTML to write. The reason for not writing with WPS (or word) is also because of the VCs, or the text that is not binary is well controlled. However, the header in the HTML does not have Word automatic numbering function, if one day in the middle of a pile header inserted A, it is necessary to the back of the numbering all upset, change up pain. So I think of jquery, use it to number, and try to get a sledgehammer.

01 $(function(){
02Var Indexs= [0, 0, 0];
03$(": Header").each(function(){
04Var Content = $(This).Html();
05If($(This).Is("H1")){
06Indexs[0]++;
07 Indexs[1] = 0;
08Content = "" + Indexs[0] + ". " + Content;
09} Else If($(This).Is("H2")){
10Indexs[1]++;
11Indexs[2] = 0;
12Content = "" + Indexs[0] + "." + Indexs[1] + ". " + Content;
13} Else If($(This).Is("H3")){
14Indexs[ 2 ] + +;
            Content = "" + indexs [ 0 ] + "." + Indexs [ 1 ] + .
                + Indexs [ 2 ] + "." + content;
        }
         $ ( this ). HTML ( content);
    });
};  

Haha, the effect is not bad. But in fact this code is the second edition, the beginning of the time is according to H1, H2, H3 to search, to deal with more trouble. In particular, H3 is also placed in a class-content div, with the jquery option used: The one-filter, like this:

var h3 = $ (this). Nextall (". Content:first"). Children ("H3");

Later thought, the description of many paths are replaced by variables, such as $ (php_home), as a color identification, so added such a piece of code in the $ (function () {...}) In


    $ (. Path" ). Each ( function () {
        var content = $ ( this ). HTML ();
        Content = content . Replace (/(\$\ (. *?\))/, $1 " "
        $ ( this ). HTML ( content);
    }

Luckily all my paths are wrapped up, just find all the. Path objects and use regular expressions to put $ (...) It's better to replace it.

In general, people who are familiar with CSS are quick to write jquery. Looking at a simple tutorial, and then browsing through the jquery document, for an hour, you can learn jquery, and it works well. No wonder so many people like it!

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.