Search code examples
jqueryeventshtml-tableonblur

JQuery Add an event to all cells in a n-th column


I am trying to add an onblur to each cell with an input in the specific column of the html table after table is created?

  $('#tableid td:nth-child(4) input').blur(function() { 
        alert('123')
     });

However, nothing happens when cell looses focus.


Solution

  • I used method found here: https://stackoverflow.com/a/40562247/3934049. Everything works as expected now.

      $(document).on("blur","#tableid td:nth-child(4) input", function() { 
        alert(123);
      });