How to access the next element and check if it has a particular class

Posted by NaN on Stack Overflow See other posts from Stack Overflow or by NaN
Published on 2014-06-09T21:22:18Z Indexed on 2014/06/09 21:24 UTC
Read the original article Hit count: 169

Filed under:

I need to call a function based on whether the second following td element has a certain class.

Here is the HTML

<tr id="939">
  <td data-id="939">Test2</td>
  <td class="hold" data-id="939"></td>
</tr>

<tr id="938">
  <td data-id="938">Test1</td>
  <td class="someotherclass" data-id="938"></td>
</tr>

Here is the JQuery function

$('body').on('click', '#article td:first-child', function(e){

    // I need to check the next td for the hold class
    if($(this).next().hasClass(".hold")){
    // Call my function
    }
});

How do I do this? I've tried using next and closest but that yields nothing.

© Stack Overflow or respective owner

Related posts about jQuery