I'm using the following js to add rows to a table. After the rows have been added, the focus jumps to the next field below the table.
$('.attendeesCount input').change(function(){ // Delete existing rows $('.attendeesTable .cf-table-delete').each(function(){ $(this).click(); }); // Count number of rows in table var n = $(this).val(); // Add rows to table for(var i = 0; i < n; i++){ $('.attendeesTable .cf-table-add-row').click(); $('tr').last().find('td:first-of-type input').focus(); };
I added
$('tr').last().find('td:first-of-type input').focus();
to try to force the focus but it's not working; I tried both inside and outside of the for loop.
Any suggestions? Thanks!