call jQuery within a javascript function using a 'this' pointer

call jQuery within a javascript function using a 'this' pointer

  1. <html>
  2.   <head>
  3.     <style type="text/css">
  4.       .selected{
  5.         background-color: red;
  6.       }
  7.     </style>
  8.     <script src="http://code.jquery.com/jquery-latest.min.js"></script>
  9.     <script> 
  10.       function click(cell){
  11.       alert(cell);
  12.       if (cell == 3)
  13.         jQuery(this).toggleclass("selected");
  14.     } 
  15.     </script>
  16.   </head>
  17.   <body>
  18.     <table border="1px">
  19.       <tr>
  20.         <td onclick="click(1)">Cell 1</td>
  21.         <td onclick="click(2)">Cell 2</td>
  22.         <td onclick="click(3)">Cell 3</td>
  23.       </tr>
  24.       <tr>
  25.         <td onclick="click(4)">Cell 4</td>
  26.         <td onclick="click(5)">Cell 5</td>
  27.         <td onclick="click(6)">Cell 6</td>
  28.       </tr>
  29.     </table>
  30.   </body>
  31. </html>

I would like for jQuery to change the class of the <td> cell that I click. I need the jQuery inside of a function, since I only want it to toggle depending on a passed in parameter. My code doesn't seem to work though. What am I doing wrong?

Thanks