Bootstrap 在引导输入组插件中使用jQuery datepicker

t5zmwmid  于 2022-12-07  发布在  Bootstrap
关注(0)|答案(2)|浏览(158)

我有一个bootstrap input group。一个搜索字段,一个date field,一个用于样式的dropdown字段,以及search button。在date field中,这是一个包含类'input-group-addon'的span,我试图添加一个jQuerydatepicker
我希望它看起来像这样

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="row">
  <form id="jumbotronForm" action="/Home/Events" method="get">
    <div class="input-group input-group-lg" style="padding-right: 200px;">
      <input id="jumbotronSearch" type="text" style="max-width: none;" class="form-control" placeholder="Location" aria-describedby="jumbotronDate">
      <span class="input-group-addon">08/28/2017</span>

      <div class="input-group-btn">
        <button id="jumbotronStyle" type="button" class="btn btn-default dropdown-toggle" style="border-radius: 0px;" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Style <span class="caret"></span></button>
        <ul class="dropdown-menu dropdown-menu-right">
          <li><a href="#">Action</a></li>
          <li><a href="#">Another action</a></li>
          <li><a href="#">Something else here</a></li>
          <li role="separator" class="divider"></li>
          <li><a href="#">Separated link</a></li>
        </ul>
        <button id="jumbotronSubmit" class="btn btn-default" type="button">Search!</button>
      </div>
    </div>
  </form>
</div>

但问题是jquery日期选择器只在输入字段中运行,所以我尝试在input-group-addon中插入一个输入,但它会弄乱样式。
此处显示

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="row">
  <form id="jumbotronForm" action="/Home/Events" method="get">
    <div class="input-group input-group-lg" style="padding-right: 200px;">
      <input id="jumbotronSearch" type="text" style="max-width: none;" class="form-control" placeholder="Location" aria-describedby="jumbotronDate">
      <span class="input-group-addon"><input id="jumbotronDate" value="08/28/2017" /></span>

      <div class="input-group-btn">
        <button id="jumbotronStyle" type="button" class="btn btn-default dropdown-toggle" style="border-radius: 0px;" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Style <span class="caret"></span></button>
        <ul class="dropdown-menu dropdown-menu-right">
          <li><a href="#">Action</a></li>
          <li><a href="#">Another action</a></li>
          <li><a href="#">Something else here</a></li>
          <li role="separator" class="divider"></li>
          <li><a href="#">Separated link</a></li>
        </ul>
        <button id="jumbotronSubmit" class="btn btn-default" type="button">Search!</button>
      </div>
    </div>
  </form>
</div>

我知道jQuery datepicker也可以在一个按钮上运行,我应该使用它吗?我知道我可以将多个按钮作为插件添加到一个输入组

9lowa7mx

9lowa7mx1#

只需增加文本框的z轴即可。

cld4siwp

cld4siwp2#

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="row">
  <form id="jumbotronForm" action="/Home/Events" method="get">
    <div class="input-group input-group-lg" style="padding-right: 200px;">
      <input id="jumbotronSearch" type="text" style="max-width: none;" class="form-control" placeholder="Location" aria-describedby="jumbotronDate">
      <span class="input-group-addon"><input id="jumbotronDate" value="08/28/2017" style="border:none; background:none; text-align:center; padding:0; width:100px" /></span>

      <div class="input-group-btn">
        <button id="jumbotronStyle" type="button" class="btn btn-default dropdown-toggle" style="border-radius: 0px;  " data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Style <span class="caret"></span></button>
        <ul class="dropdown-menu dropdown-menu-right">
          <li><a href="#">Action</a></li>
          <li><a href="#">Another action</a></li>
          <li><a href="#">Something else here</a></li>
          <li role="separator" class="divider"></li>
          <li><a href="#">Separated link</a></li>
        </ul>
        <button id="jumbotronSubmit" class="btn btn-default" type="button">Search!</button>
      </div>
    </div>
  </form>
</div>

相关问题