In the table of jQuery_review, the background color and checkbox are selected based on the row. In jquery, the checkbox is selected.

Source: Internet
Author: User

In the table of jQuery_review, the background color and checkbox are selected based on the row. In jquery, the checkbox is selected.
Continue to review jQuery. For table, in addition to single choice, there is also a control for multiple choices. For multiple selections, You need to highlight the selected content. You should also highlight the selected content by default when loading the page. These small functions are also a good material for reviewing the jQuery selector. There are many implementation methods, not just sticking to one, as long as the function can be robust, it is quite good.

In a document, I saw such a jQuery writing method, which is still amazing! Element [hasClassName? "RemoveClass": "addClass"] ("className"). The content in the brackets is a three-object expression. The result of the Three-object expression can be an operation with the subsequent parameter itinerary. Is removeClass () or addClass (). This is still very good and reflects the purpose of jQuery's design. from another perspective, it also reflects the powerful aspect of the explanatory language. In this Java, c ++ is not easy to understand.


<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">



Jquery has multiple checkboxes in the table. How can I check whether the first checkbox in each row is selected?

$ ("Table tr "). each (function (index, item) {var firstInput = $ (this ). children ("td: eq (0)"); // The first checkBox var secondTd = $ (this ). children ("td: eq (1)") secondTd. text (); // td value var inputs = secondTd. nextAll (); // the CheckBox behind it })

How does jquery select all checkpoints in the table?

$ ("Table input [type = checkbox]")
You can.
Then you can execute $ ("table input [type = checkbox]"). attr ("checked", true) and so on.

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.