I have a series of inputs listed within table cells like spreadsheet. I'm simply trying to get jquery to figure out which column they're in when I start typing. I'd like to to this without putting identifiers in the columns themselves.
I've made a couple of attempts using jquery's index, but I'm obviously missing something. When I try to get the index of the table data (td), I get it for the document, not for its parent. When I try to specify the parents and children, it doesn't seem to be a thing that index does. Thanks in advance for any help.
$('tr td input').live('keyup',function(e){
/* attempt 1, returns nth td in document instead of the nth td in the table row
var column = $(this).parent().index('td');
$('#column').val(column);
*/
/* attempt two */
$parentRow = $(this).parents('tr');
$parentCell = $(this).parent('td');
var $column = $(this).parent('td').index('tr');
// insert column number into #column
var $column = ($parentRow).index($parentCell);
$('#column').val($column);
});