Jquery Selects all instance code-jquery

Source: Internet
Author: User
This article introduces the sample code based on jquery code, which is easy to understand and practical, if you are interested in learning it together, this article will share with you a piece of code based on jQuery's full selection, reverse selection, and unselection functions. This is suitable for scenarios where multiple web pages require batch operations (such as batch deletion ). This article uses examples to simplify the code and covers all aspects of the Option Selection operation, hoping to help WEB enthusiasts who need it.

// Select all

$ ('# Checkall '). click (function () {// determine if var bischecked is selected = $ ('# checkall '). is (': checked'); var fruit = $ ('input [name = "check"]'); bischecked? Fruit. attr ('checked', true): fruit. attr ('checked', false );});

// Re-select the checkbox. If it is selected, it is set to deselected. Otherwise, it is the same.

 $("#tabVouchList tr").each(function () {  if ($("td:eq(0) input[name='check']", $(this)).is(':checked')) {   $(this).attr('checked', false);  } else {   $(this).attr('checked', true);  } });

HTML table

 
 
Row number Name
Row number Name

The above code is all the code for jquery to achieve full selection without selecting the inverse. Is the code very simple? I hope it will be helpful for everyone's work and learning.

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.