The previous blog wrote a check box, this is a radio box, sometimes query, can only select a record, if the selected row of the record highlighted, and the line radio button is also selected, this will improve the user experience. Today's era is the era of user experience.
The effect is as follows:
The CSS file looks like this:
Copy Code code as follows:
. selected{
Background: #FF6500;
Color: #fff;
}:
This time the JS file's code becomes simpler, as follows:
Copy Code code as follows:
/**
* Set the background color of the table containing the radio buttons
*/
$ (document). Ready (function ()
{
/**
* Change the background color when the table is clicked
*/
$ ("#tablight tr:gt (0)"). Click (function ()//Get line 2nd and later
{
$ (this). AddClass ("selected"). Siblings (). Removeclass ("selected"). End (). FIND (": Radio"). attr ("Checked", true);
});
});
If you want the code to take effect, you need to add an id attribute to the table with the property value "Tablight". Once this is done, just refer to the two files when you use them.