Jquery controls table row highlighting instances

Source: Internet
Author: User

[Css]
Copy codeThe Code is as follows:
<Style>
. Height {
Background: #666666;/* the background color is gray */
}
Tr {
Cursor: pointer;/* hand shape */
}
</Style>

<Style>
. Height {
Background: #666666;/* the background color is gray */
}
Tr {
Cursor: pointer;/* hand shape */
}
</Style>

[Html]
Copy codeThe Code is as follows:
<Body>
<Table border = "1" width = "40%">
<Tr> <th> </th> <th align = "left"> name </th> <th align = "left"> gender </th> <th align = "left"> Place of Residence </th> </tr>
<Tr>
<Td> <input type = "radio" name = "radio"/> </td> <td> Zhang San </td> <td> male </td> <td> beijing </td>
</Tr>
<Tr>
<Td> <input type = "radio" name = "radio"/> </td> <td> Li Si </td> <td> male </td> <td> shanghai </td>
</Tr>
<Tr>
<Td> <input type = "radio" name = "radio"/> </td> <td> Wang Wu </td> <td> female </td> <td> shenzhen </td>
</Tr>
<Tr>
<Td> <input type = "radio" name = "radio"/> </td> <td> Zhao liu</td> <td> female </td> <td> Beijing </td>
</Tr>
<Tr>
<Td> <input type = "radio" name = "radio"/> </td> <td> Sun Qi </td> <td> male </td> <td> Shanghai </td>
</Tr>
</Table>
</Body>

<Body>
<Table border = "1" width = "40%">
<Tr> <th> </th> <th align = "left"> name </th> <th align = "left"> gender </th> <th align = "left"> Place of Residence </th> </tr>
<Tr>
<Td> <input type = "radio" name = "radio"/> </td> <td> Zhang San </td> <td> male </td> <td> beijing </td>
</Tr>
<Tr>
<Td> <input type = "radio" name = "radio"/> </td> <td> Li Si </td> <td> male </td> <td> shanghai </td>
</Tr>
<Tr>
<Td> <input type = "radio" name = "radio"/> </td> <td> Wang Wu </td> <td> female </td> <td> shenzhen </td>
</Tr>
<Tr>
<Td> <input type = "radio" name = "radio"/> </td> <td> Zhao liu</td> <td> female </td> <td> Beijing </td>
</Tr>
<Tr>
<Td> <input type = "radio" name = "radio"/> </td> <td> Sun Qi </td> <td> male </td> <td> Shanghai </td>
</Tr>
</Table>
</Body>

Jquery

[Javascript]
Copy codeThe Code is as follows:
Plaincopyprint? $ (Document). ready (function (){
// The first method: $ ("tr: gt (0)") the title of the first line does not work.
$ ("Tr: gt (0)"). click (function (){
$ (This ). addClass ("height "). siblings (). removeClass ("height "). end (). find (": radio "). attr ("checked", true );
})

// Method 2: $ ("tr: not (: first )")
/* $ ("Tr: not (: first)"). click (function (){
$ (This ). addClass ("height "). siblings (). removeClass ("height "). end (). find (": radio "). attr ("checked", true );
})*/
})

$ (Document). ready (function (){
// The first method: $ ("tr: gt (0)") the title of the first line does not work.
$ ("Tr: gt (0)"). click (function (){
$ (This ). addClass ("height "). siblings (). removeClass ("height "). end (). find (": radio "). attr ("checked", true );
})

// Method 2: $ ("tr: not (: first )")
/* $ ("Tr: not (: first)"). click (function (){
$ (This ). addClass ("height "). siblings (). removeClass ("height "). end (). find (": radio "). attr ("checked", true );
})*/
})

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.