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
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: