Home > Web Front-end > JS Tutorial > body text

jquery implements highlighting of table rows with radio buttons when selected_jquery

WBOY
Release: 2016-05-16 17:27:30
Original
1496 people have browsed it

The last blog post was about check boxes, this time it is about radio buttons. Sometimes when querying, only one record can be selected. If the row of the selected record is highlighted, the single button of the row will also be displayed. The select 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 the code The code is as follows:

.selected{
background:#FF6500;
color:#fff;
}:

This time the code of the js file becomes Even simpler, as shown below:
Copy the code The code is as follows:

/**
* Set the background color of the table containing radio buttons
*/
$(document).ready(function()
{
/**
* Change the background color when the table is clicked
*/
$("#tablight tr:gt(0)").click (function() //Get
{
$(this).addClass("selected").siblings().removeClass("selected").end().find(" :radio").attr("checked",true);
});
});

If you want the code to take effect, you need to add the id attribute to the table. The attribute value is "tablight". Once this is done, just reference these two files when using it.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!