0

我目前有这个脚本,它在文本框旁边给了我一个图像。如果我单击图像,它会显示日期选择器:

$("#txtDate").datepicker({
    changeMonth: true,
    changeYear: true,
    yearRange: "+0:+1",
    showButtonPanel: false,
    dateFormat: "dd/mm/yy",
    showOn: "button",
    buttonImage: "image.png",
    buttonImageOnly: true,
    onClose: function() {

        selectedDateTime($("#txtDate").val(), $("#ddlHourTime").val(), $("#ddlMinuteTime").val());

    }
});

如何更改此设置,以便在单击文本框或图像时显示日期选择器。目前,当我单击文本框时没有任何反应。

4

1 回答 1

2

您的问题是您如何设置showOn。它设置为“按钮”,因此它只会在单击时打开日期选择器。将其更改为“两者”,它将在两个文本框单击 abe 按钮单击时打开。

这是一个jsfiddle

$("#txtDateBoth").datepicker({
    changeMonth: true,
    changeYear: true,
    yearRange: "+0:+1",
    showButtonPanel: false,
    dateFormat: "dd/mm/yy",
    showOn: "both",
    buttonImage: "image.png",
    buttonImageOnly: true,
});
于 2013-10-02T12:25:44.870 回答