how to select just a row of table using jquery

Posted by user1400 on Stack Overflow See other posts from Stack Overflow or by user1400
Published on 2010-04-29T07:11:19Z Indexed on 2010/04/29 7:17 UTC
Read the original article Hit count: 355

Filed under:
|
|
|

hello

i have created a table on my application same follwing code

<table class="spreadsheet">
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>6</td>
</tr>
</table>

i select a row by click with following jquery code

 $("tr").click(function(){
 $(this).toggleClass("otherstyle");
}

and my css is

tr.otherstyle td
{
    background-color: #d1db3e;
    color:#000;
}

i would like when i click on a row, other rows be unselected

and just one row be selected

how we could create this?

thanks

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about table