定位日期选择器按钮

时间:2019-02-06 10:57:05

标签: jquery asp.net-mvc jquery-ui jquery-ui-datepicker

我正在使用ASP.Net和jQuery开发我的网站。我正在使用一个月选择器控件。我想将按钮放在输入旁边以显示日期。谁能帮我吗?

<div class="col-lg-3">
  @Html.TextBox("IconDemo", DateTime.Today.ToString("MM/yyyy"), new { @id = "IconDemo", @class = "Default form-control form-control-sm", @readonly = true })
</div>
$("#IconDemo").MonthPicker({
  Button: "<button id='btmonthpicker' class='btn btn-warning btn-sm' ><i class='fa fa-calendar'></i></button>",
  Position: {
    collision: 'fit',
    at: 'left top',
    my: 'left bottom',
    of: $('#IconDemo')
  },
  format: "mm-yy",
  startView: "months",
  minViewMode: "months",
  MaxMonth: 0,
  MaxYear: 0,
});

enter image description here

1 个答案:

答案 0 :(得分:0)

我找到了解决此问题的方法

<div class="col-lg-3">
  <div class="pull-right">
  @Html.TextBox("IconDemo", DateTime.Today.ToString("MM/yyyy"), new { @id = "IconDemo", @class = "Default form-control form-control-sm", @readonly = true })
</div>
</div>

这只是向包含datepicker的div中添加了pull-right类