Jquery enables highlighted display during row selection of tables with single-choice buttons

Source: Internet
Author: User

The previous blog wrote the check box. This time it wrote a single record. Sometimes, when querying, you can only select one record. If you highlight the row of the selected record, at the same time, the row's single-choice button is also selected, which will improve the user experience. Today's era is the era of user experience.

The effect is as follows:
The CSS file is as follows:
Copy codeThe Code is as follows:
. Selected {
Background: # FF6500;
Color: # fff;
}:

This Javascript file code becomes simpler, as shown below:
Copy codeThe Code is as follows:
/**
* Set the background color of the table containing the single-choice button.
*/
$ (Document). ready (function ()
{
/**
* The background color is changed when the table is clicked.
*/
$ ("# Tablight tr: gt (0)"). click (function () // get 2nd rows and later
{
$ (This ). addClass ("selected "). siblings (). removeClass ("selected "). end (). find (": radio "). attr ("checked", true );
});
});

To make the Code take effect, add the id attribute to the table. The attribute value is "tablight ". Once this is done, you only need to reference the two files when using it.

Related Article

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.