pickadate - jQuery - getting text from attribute -
i'm using plugin called pickadate , i'm trying aria label text chosen date , apply onto div. im able retrieve value once if click on day date in #date doesn't update?
var $elements = { datepicker: $('.js-datepicker'), }; $elements.datepicker.pickadate(); $('.picker__day').on('click', function () { var date = $(this).attr('aria-label'); $('#date').empty().text(date); });
as described in docs datepicker plugin can use onset
event retrieve current date has been set.
the onset event callback passed context argument provides details properties being “set”.
within scope of 6 of these events, this refers picker.
$('.js-datepicker').pickadate({ onset: function() { $('#date').text(this.$node.val()); } });
#date{ font-weight:bold; font-size:40px; margin:20px 0; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="http://amsul.ca/pickadate.js/vendor/pickadate/lib/picker.js"></script> <script src="http://amsul.ca/pickadate.js/vendor/pickadate/lib/picker.date.js"></script> <input class="js-datepicker" type="text" placeholder="select date" /> <div id="date"></div>
here can find more information on that.
Comments
Post a Comment