jquery Tutorial: 14 Practical jquery Tips

Source: Internet
Author: User
Tags contains version wrapper

jQuery is so popular and is widely used by almost everyone from big companies to personal blogs because it's easy to get started and used, and it gives us pretty good features that some people don't know about. I think most users of jquery are more likely to use jquery plug-ins to address the challenges they face, which is often a wise choice. But when there are some flaws in the plug-in relative to your needs, you may want to find a way to solve it yourself, and look at these practical jquery techniques, and they will certainly come in handy!

1. Test and upgrade your jquery selector level

This jquery selector lab is cool, it can be used online for free, but you can also go down to the local offline use. This test page contains complex HTML combination fields, and then you can try predefined use of various jquery selectors. If that's not enough, you can also customize the selector.

2. Test if the jquery wrapper set contains some elements

If you want to test whether a jquery wrapper set contains elements, you can first try to verify that the first element exists:

if ($ (selector) [0]) {...}
Or so
if ($ (selector). Length) {...}

Take a look at this example:

Example. If your page has the following HTML code


  • item x

  • item y

  • item z


This if condition will return true, because we have two
The input field matches the selector, so the code will execute
if ($ ("#shopping_cart_items input.in_stock") [0]) {}

3. Read jquery latest version from jquery.org

You can use this code to read the latest version of jquery's code file.

You can use this method to invoke the most recent version of the jquery framework, and of course you can use the following code to invoke the same latest version of jquery from ajax.googleapis.com:



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.