Get next element in td

yooouuri
<table>
    <tr>
        <td><span data-....></span></td> // 1
        <td><a href="">....</a><td>
        <td><span data-....></span></td> // 2
        <td><a href="">....</a><td>
        <td><span data-....></span></td> // 3
        <td><a href="">....</a><td>
    </tr>
</table>

When i click on the span, how do i find the next span?

The span transforms in a input, when i press the TAB button i want to go to the next span...

Between every span there is a a href.. Without the a hrefs it work

$('table td span').hover(function () {
    $(this).css('cursor','pointer');
});

$(document).on('keydown', 'table td input', function(event) {
    var target = $(this);

    if (event.which == 9) {
        event.preventDefault();

        console.log('Tab pressed');

        var span = target.parent().next().find('span');

        span.click();

        console.log(span.data('date'));
    }
});
ibrahim mahrir
$('table td').on('click', 'span', function(event) {
    $(this).parent()         // the parent of the span
           .next()           // the next element to that parent (href td)
           .next()           // the next element to that next element (span td)
           .find('span');    // the span children of the first
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related