ZVe*_*nue 2 asp.net-mvc jquery jquery-ui datepicker
我需要显示jQuery UI Datepicker插件,Html.TextBox我该怎么做?
jQuery代码:
<script>
$(function () {
$("#datepicker").datepicker();
});
</script>
<div class="demo">
<p>Date: <input type="text" id="datepicker" style = "width:150px"/></p>
</div>
Run Code Online (Sandbox Code Playgroud)
上面的代码在我的MVC视图中为我提供了一个文本框控件,我可以在其中单击控件并弹出日历控件,它运行良好,但我想要的是重现相同的行为,Html.Textbox我将在稍后使用代码,像这样:
<%= Html.TextBox("Date", "", new { style = "width:150px"})%>
Run Code Online (Sandbox Code Playgroud)
如何让jQuery UI Datepicker插件在上面的代码行中运行?
加入class="datepicker"你的htmlAttributes
<script>
$(function () {
$(".datepicker").datepicker();
});
</script>
<div class="demo">
<p>Date: <input type="text" id="datepicker" style = "width:150px"/></p>
</div>
<%= Html.TextBox("Date", "", new { style = "width:150px", @class = "datepicker"})%>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18400 次 |
| 最近记录: |