Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<style type="text/css" media="screen">
body { background-color: #000; font: 16px Helvetica, Arial; color: #fff; }
table tr th { background-color:green; }
table tr td { background-color:red; }
</style>
</head>
<body>
  <table border="0" cellspacing="5" cellpadding="5">
    <tr><th>This 1</th><th>This 2</th><th>This 3</th><th>This 4</th></tr>
    <tr id="myid"><td>Data 1</td><td>Data 2</td><td>Data 3</td><td>Data 4</td></tr>
    <tr id="try2"><td>Data 1</td><td>Data 2</td><td>Data 3</td><td>Data 4</td></tr>
    <tr id="try3"><td>Data 1</td><td>Data 2</td><td>Data 3</td><td>Data 4</td></tr>
    <tr id="try4"><td>Data 1</td><td>Data 2</td><td>Data 3</td><td>Data 4</td></tr>
  </table>
</body>
</html>
 
gto$(document).ready(function(){
  $('tr#try2').click(function(){
    $(this).closest('tr:nth-last-of-type(2n+2)').css({ 'background-color' : 'white'});
    $(this).closest('tr').css({ 'background-color' : 'yellow' });
  }); 
});
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers