i've looked in the manual to search for the next value in a table but the problem is that i'm in the first span cell 'cause of the event catch by :
jQuery code:
$('span[name="checkSeleccion"]').live('click',function(){
alert($(this).attr('id')+"::"+$(this).next('td').html());
});
HTML code:
<tbody>
<tr>
<td>
<span id="606" class="checkboxClear" rel="606-null-335" name="checkSeleccion"> </span>
</td>
<td style="padding-top:6px;">http://www.hithere.com</td>
<td align="center" style="padding-top:6px;">335</td>
</tr>
</tobdy>
is there a way to catch the second td value when the span is clicked?
Thanks.
Change this:
$(this).next('td')
to this:
$(this).parent('td').next('td')
添加.parent()选择器:
alert($(this).attr('id')+"::"+$(this).parent().next('td').html()); });
You forgot to use .parent()
:
$('span[name="checkSeleccion"]').live('click', function() {
alert(this.id + "::" + $(this).parent().next('td').html());
});
Also note that $(this).attr('id')
could be written as just this.id
, which is much more efficient (and easier to type!).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.