Jquery exclusion method

Source: Internet
Author: User

There are many jquery selectors. There are many ways to select a DOM. How can we exclude a certain element set? The following are examples:

(1) Select All img elements to exclude the number of elements in class = phpernote:

$ ('Img: not (. phpernote) '). length (); // or $ ('img'). not ('. phpernote'). length ();

(2) obtain the number of li elements without class = com under id = phpernote

$ ('# Phpernote li: not (. com )'). size (); // or $ ('# phpernote li '). not ('. com '). length ();

(3) set the background of the li element of all odd rows under id = phpernote

$ ('# Phpernote li'). not (': even'background .css ('background-color', 'red ');

For details about the usage of the jquery selector, refer to this site:

JQuery selector usage Summary

Articles you may be interested in
  • Using JavaScript to prohibit browsers from directly copying article content
  • Php clears the null element in the array.
  • How does jquery operate on iframe parent page elements?
  • How to insert an element to the front of the body element in js
  • JQuery selector usage Summary
  • Jquery obtains the index number of the current element in the Peer element.
  • How to locate, eliminate and avoid MySQL database performance problems
  • How does php Delete the first and last elements of an array?

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.