[jQuery]DataList + click + toggleClass

  • 1508
  • 0

[jQuery]DataList + click + toggleClass

 

DataList 產生的html code

   1:      <table id="ctl00_ContentPlaceHolder1_Jobs" cellspacing="0" border="0" style="border-collapse:collapse;">
   2:          <tr>
   3:                  <td>
   4:                          <a href='...'>xxx</a>
   5:                  </td>
   6:          </tr>
   7:          <tr>
   8:                  <td>
   9:                          <a href='...'>xxx</a>
  10:                  </td>
  11:          </tr>
  12:          <tr>
  13:                  <td>
  14:                          <a href='...'>xxx</a>
  15:                  </td>
  16:          </tr>
  17:      </table>

 

切換 hightlight

   1:              $Jobs.delegate('a', 'click', function() {
   2:                  var $this = $(this);
   3:                  $this.parent().parent().parent().find('.highlight').each(function() {
   4:                      $(this).toggleClass();
   5:                  });
   6:                  $this.toggleClass('highlight');
   7:              });