Bind the .datepicker() to new input elements

2019-08-02 15:33发布

问题:

I am trying to add the datepicker to input elements created on the fly.I understood the usage of .on() or .live() function but I can't find the right event to bind them on:

Trying to use .on since live() got depercated I succeded the following: On input field click it's turned into a datepicker input

 $("#container").on("click", ".date", function(){
        $(this).datepicker()
  });

But I need this on the onload event which does not exist on inputs.