开发者

how to assign datetimepicker to this label using jquery

开发者 https://www.devze.com 2022-12-30 08:49 出处:网络
<label for=\"Date\"> dateformate: <span id=\"date-<%=Model.ID%>\"><%=Html.EditorFor(model => model.Date)%></span>
 <label for="Date">
            dateformate:
            <span id="date-<%=Model.ID%>"><%=Html.EditorFor(model => model.Date)%></span>
        </label>

I need to assign datet开发者_开发技巧imepicker for this lable? when any user clicks on the date label datetimepciker should popup?


Check out the JQuery UI Datepicker.

Your case is a bit special since the ID is generated dynamically but it is still pretty easy:

$("span[id^='date-']").datepicker();

Taking a closer look, I just realized that you are trying to tie the datepicker to a span where it would normally be assigned to a textbox. So really what you are going to want is to add a textbox and then do this:

$("input[id^='date-']").datepicker();

Also make sure that you have the jQuery UI CSS referenced. Something like this on your page or site.master:

@import url(/Content/ui.all.css);
0

精彩评论

暂无评论...
验证码 换一张
取 消