jQuery datepicker won't work on a AJAX added html element

前端 未结 6 1376
小鲜肉
小鲜肉 2020-12-05 12:06

I have a jQuery datepicker function bound to the \"birthday\" input html element, written in the page header:



        
6条回答
  •  Happy的楠姐
    2020-12-05 12:38

    You could initialize the date picker for the newly added element within your ajax success callback:

     $.ajax({
    
        ...
    
        success: function(response) {
            if(response.success) {
                  $(body).append(response.html);
                  $("#birthday").datepicker();
            }
        }
     });
    

提交回复
热议问题