Making datepicker live - JQuery

后端 未结 4 751
故里飘歌
故里飘歌 2021-01-12 09:48

I know when you create an element dynamically, you have to use something like:

$(\"#id\").live(\"click\", function() {
    //something
});

4条回答
  •  既然无缘
    2021-01-12 10:16

    The accepted solution won't work with keyboard focus events.. so I had to change to this:

    $('.parent').on('focusin', '.datepicker', function(e) {
        $(this).datepicker(options);
    });
    

    Had to change .live to .on since jquery 1.9.1 doesn't include the .live method. The above works for the mouse events as well as keyboard focus events.

提交回复
热议问题