jquery - How to access the next element and check if it has a particular class -
i need call function based on whether second following td
element has class.
here 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 jquery function
$('body').on('click', '#article td:first-child', function(e){ // need check next td hold class if($(this).next().hasclass(".hold")){ // call function } });
how do this? i've tried using next
, closest
yields nothing.
edit:
i've made fiddle: http://jsfiddle.net/ndxbb/
$(this)
not refer td class getjson
. try this:
$('body').on('click', '#article td:first-child', function(e){ $nextobj = $(this).next(); //your getjson function if($nextobj.hasclass("hold")){ // call function } });
Comments
Post a Comment