开发者

how to assign datetimepicker to this label using jquery

 <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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜