Search code examples
jqueryhtmltabindex

Detecting the end of a html form's tabindex to fire a jQuery event


I have a html table with form elements in each row to add items, prices, quantities etc... to an invoice.

At the end of each table row there is an 'add' button which fires an event to add an new row of blank form elements to the bottom of the table (for a new item on the invoice).

Is there a way to detect that the last form element in the table has lost focus (tabbed passed it) and fire the event to add a new row of empty elements?

Many thanks in advance.


Solution

  • Blur's what you want. Something like this:

    $('.add-button').blur(function() {
         add_row();
    });