简体   繁体   中英

Date Calendar doesn't show

I have a .js file with the datepicker function (code given below). And I have a textbox in my aspx code that needs to get the calendar on select. I put a breakpoint in my js file and it doesn't hit file when I debug my code. Can you please help?

Picker.js file:

function () {
    $("#ToTextBox").datepicker({
        changeMonth: true,
        changeYear: true
    });
}

Aspx code:

 <asp:TextBox ID="ToTextBox" runat="server"/>

Your JS code it's not being executing when DOM is loaded, you have to wrap it in a $() object like this:

$(function () {
    $("#ToDateTextBox").datepicker({
        changeMonth: true,
        changeYear: true
    });
});

So it applies the datepicker after the website is loaded.

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