Radio Box:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >< HTML xmlns= "http://www.w3.org/1999/xhtml" xml:lang= "en" lang= "en" > $(function(){ $("Tbody>tr:odd"). AddClass ("odd");//exclude the first line and then add a style to odd rows$ ("Tbody>tr:even"). AddClass ("even");//exclude the first row and then add a style to even rows$ (' tbody>tr '). Click (function() { $( This). addclass (' Selected ') //The current object is $ (this) . Siblings (). Removeclass (' Selected ') //The current object is $ (this). Siblings () . End () //The current object is $ (this) . Find (': Radio '). attr (' checked '),true); }); //High Color If the radio box is selected by default. //$ (' table:radio:checked '). Parent (). Parent (). AddClass (' selected '); //Simplified:$ (' table:radio:checked '). Parents ("tr"). AddClass (' selected ')); //further simplification: //$ (' Tbody>tr:has (: Checked) '). AddClass (' selected '); })</script> $(function(){ $("Tbody>tr:odd"). AddClass ("odd");//exclude the first line and then add a style to odd rows$ ("Tbody>tr:even"). AddClass ("even");//exclude the first row and then add a style to even rows$ (' tbody>tr '). Click (function() { if($( This). Hasclass (' selected ')) { $( This). Removeclass (' Selected '). Find (': CheckBox '). attr (' checked ',false); }Else{ $( This). addclass (' Selected '). Find (': CheckBox '). attr (' checked ',true); } }); //If the check box is selected by default, the high color. //$ (' table:checkbox:checked '). Parent (). Parent (). AddClass (' selected '); //Simplified:$ (' table:checkbox:checked '). Parents ("tr"). AddClass (' selected ')); //$ (' Tbody>tr:has (: Checked) '). AddClass (' selected '); })</script> $(function(){ $("Tbody>tr:odd"). AddClass ("odd")); $("Tbody>tr:even"). AddClass ("even")); $(' Tbody>tr '). Click (function() { //determines whether the current selection varhasselected=$ ( This). Hasclass (' selected '); //If selected, move out of the selected class, or add the selected class$( This) [hasselected?] Removeclass ":" AddClass "] (' selected ') //[hasselected?] Removeclass ":" AddClass "] is a three-mesh operator
$ (this) ["Removeclass"] ("selceted"), or $ (this) ["AddClass"] (' selected ');
They are equivalent to: $ (this). Removeclass (' selected ') or $ (this). AddClass (' selected '); //Find the Internal checkbox and set the corresponding properties. . Find (': CheckBox '). attr (' checked ',!hasselected); }); //If the check box is selected by default, the high color.$ (' Tbody>tr:has (: Checked) '). AddClass (' selected '); })</script>collapse:collapse;} TD {Font:normal 12px/17px arial;padding:2px;width:100px;} Th {font:bold 12px/17px arial;text-align:left;padding:4px;border-bottom:1px solid #333;}. Even {background: #FFF38F;} /* even line style */ . Odd {background: #FFFFEE;} /* Odd Line Style */ . Selected {background: #FF6500; color: #fff;}
jquery Radio box check box table highlighting