jQuery UI datepicker - add static text underneath the calendar?

后端 未结 3 782
长情又很酷
长情又很酷 2020-12-21 16:22

This is on the one that pops up when you click the linked input element. I want to be able to insert some static text underneath the table of dates that will appear and stay

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-21 16:43

    One solution for presenting different texts on multiple datepickers on the same page is to create data holders next to the id/class space of each datepicker location. Then load the data content for the datepicker selected using (this).

    Example html code: The data holder contains the specific text to be displayed for the associated datepicker like so:

    Date1:

    Date2:

    Example jQuery code: Then the jQuery text injection into the selected datepicker calendar would be something like this:

    $( ".datepicker" ).datepicker()
        .on( "click", function() {
            var dTxt = $( this ).data('dptxt');
        $('.ui-datepicker-calendar').after(''+dTxt+'');
    });
    

    I've added a little CSS formatting so that you can easily see the additional semi-dynamic text changing between the two datepickers.

    See my working jsFiddle solution in action (images below from the jsFiddle link :)


    (source: web-asylum.com)

提交回复
热议问题