简体   繁体   中英

jQuery each function not working after ajax call

I have this below code that works on initial page load but after the ajax call, it is not working.

 $.each($(document).find("[data-type='datepicker']"), (function (index, element) {
     $(element).datepicker({
         dateFormat: 'dd M yy'
     });
 }));

How to use event handler with .each function?

Thanks for your suggestions!

You don't need to use $.each just use your datepicker selector like,

$("[data-type='datepicker']").datepicker({
     dateFormat: 'dd M yy'
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM