Retrieve Table Row Index of Current Row

Posted by Jon on Stack Overflow See other posts from Stack Overflow or by Jon
Published on 2010-03-30T13:37:32Z Indexed on 2010/03/30 13:43 UTC
Read the original article Hit count: 375

Filed under:
|
|
|

Hi Everyone,

I am trying to validate a text input when it loses focus. I would like to know which row of the table it is in. This is what I have so far and it keeps coming back as undefined. Any ideas?

$("div#step-2 fieldset table tbody tr td input").blur(function() {
    var tableRow = $(this).parent().parent();
    if ($.trim($(this).val()) == "") {
        $(this).addClass("invalid");
        alert(tableRow.rowIndex);
        $(this).val("");
    } else {
        $(this).removeClass("invalid");
        checkTextChanges();
    }
});

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about table