Apply jQuery datepicker to multiple instances

后端 未结 12 2366
时光说笑
时光说笑 2020-11-27 14:04

I\'ve got a jQuery date picker control that works fine for once instance, but I\'m not sure how to get it to work for multiple instances.



        
12条回答
  •  生来不讨喜
    2020-11-27 14:51

    When adding datepicker at runtime generated input textboxes you have to check if it already contains datepicker then first remove class hasDatepicker then apply datePicker to it.

    function convertTxtToDate() {
            $('.dateTxt').each(function () {
                if ($(this).hasClass('hasDatepicker')) {
                    $(this).removeClass('hasDatepicker');
                } 
                 $(this).datepicker();
            });
        } 
    

提交回复
热议问题