最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - How to use datepicker.min.js?

programmeradmin2浏览0评论

On my site I load datepicker.min.js

    <script type='text/javascript' src='http://xxx/wp-includes/js/jquery/ui/core.min.js?ver=1.11.4'></script>
    <script type='text/javascript' src='http://xxx/wp-includes/js/jquery/ui/datepicker.min.js?ver=1.11.4'></script>
    <script type='text/javascript'>
jQuery(document).ready(function(jQuery){jQuery.datepicker.setDefaults({"closeText":"Fermer","currentText":"Aujourd\u2019hui","monthNames":["janvier","f\u00e9vrier","mars","avril","mai","juin","juillet","ao\u00fbt","septembre","octobre","novembre","d\u00e9cembre"],"monthNamesShort":["Jan","F\u00e9v","Mar","Avr","Mai","Juin","Juil","Ao\u00fbt","Sep","Oct","Nov","D\u00e9c"],"nextText":"Suivant","prevText":"Pr\u00e9c\u00e9dent","dayNames":["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"],"dayNamesShort":["dim","lun","mar","mer","jeu","ven","sam"],"dayNamesMin":["D","L","M","M","J","V","S"],"dateFormat":"MM d, yy","firstDay":1,"isRTL":false});});
</script>

So I wish to add a datepicker to my input

<input type="text" class="mkdf-filter-min-date" name="min_date" placeholder="Check-in:" value="<?php echo esc_attr( $today ) ?>"/>

But i don't find how to do.

On my site I load datepicker.min.js

    <script type='text/javascript' src='http://xxx/wp-includes/js/jquery/ui/core.min.js?ver=1.11.4'></script>
    <script type='text/javascript' src='http://xxx/wp-includes/js/jquery/ui/datepicker.min.js?ver=1.11.4'></script>
    <script type='text/javascript'>
jQuery(document).ready(function(jQuery){jQuery.datepicker.setDefaults({"closeText":"Fermer","currentText":"Aujourd\u2019hui","monthNames":["janvier","f\u00e9vrier","mars","avril","mai","juin","juillet","ao\u00fbt","septembre","octobre","novembre","d\u00e9cembre"],"monthNamesShort":["Jan","F\u00e9v","Mar","Avr","Mai","Juin","Juil","Ao\u00fbt","Sep","Oct","Nov","D\u00e9c"],"nextText":"Suivant","prevText":"Pr\u00e9c\u00e9dent","dayNames":["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"],"dayNamesShort":["dim","lun","mar","mer","jeu","ven","sam"],"dayNamesMin":["D","L","M","M","J","V","S"],"dateFormat":"MM d, yy","firstDay":1,"isRTL":false});});
</script>

So I wish to add a datepicker to my input

<input type="text" class="mkdf-filter-min-date" name="min_date" placeholder="Check-in:" value="<?php echo esc_attr( $today ) ?>"/>

But i don't find how to do.

Share Improve this question asked Dec 2, 2019 at 13:55 GregoryGregory 6025 silver badges20 bronze badges 3
  • you have to add JavaScript to bind the input tag to the datepicker : jqueryui/datepicker – Kaperto Commented Dec 2, 2019 at 14:00
  • and how do you do this ? – Gregory Commented Dec 2, 2019 at 14:01
  • i found my solution, thank you – Gregory Commented Dec 2, 2019 at 14:07
Add a comment  | 

1 Answer 1

Reset to default 0

ok, i got it, i was adding it to input name & not input class !

<script type="text/javascript">
jQuery(document).ready(function($) {
    $('.mkdf-filter-min-date').datepicker({
        dateFormat : 'yy-mm-dd'
    });
});
</script>
发布评论

评论列表(0)

  1. 暂无评论