12
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Bootstrapのdropdownメニューにテキストフォームを実装する

Last updated at Posted at 2014-08-18

Bootstrapのdropdownはclickすると閉じる実装になっているので、textformにfocusした瞬間に閉じてしまう。
そこでjsでdropdown自体をclickしても閉じないようにする。

html
<div class="dropdown-menu_wrapper">
  <a class="dropdown-toggle" data-toggle="dropdown">
    <p>メニュー</p>
  </a>
  <div class="dropdown-menu" role="menu">
    <ul>
      <li>
        <input type="text" name="example1">
      </li>
      <li>
        <input type="text" name="example2">
      </li>
      <li>
        <input type="text" name="example3">
      </li>
    </ul>
  </div>
</div>
js
$(document).ready(function() {
    $(".dropdown-menu").click(function(e) {
        e.stopPropagation();
    }); 
});
12
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?