Bootstrap搜索栏上的jquery自动完成

时间:2015-12-28 21:49:38

标签: javascript jquery twitter-bootstrap

是否可以将Jquery自动完成放入引导搜索栏。所以当有人使用搜索栏时,他们会显示下面的标签?

jquery自动完成

 $(function() {
var availableTags = [
  "ActionScript",
  "AppleScript",
  "Asp",
  "BASIC",
  "C",
  "C++",
  "Clojure",
  "COBOL",
  "ColdFusion",
  "Erlang",
  "Fortran",
  "Groovy",
  "Haskell",
  "Java",
  "JavaScript",
  "Lisp",
  "Perl",
  "PHP",
  "Python",
  "Ruby",
  "Scala",
  "Scheme"
];
$( "#text" ).autocomplete({
  source: availableTags
});

});

Bootstrap搜索栏

  <div class="col-lg-4 col-md-5 col-sm-3">
                <form class="navbar-form" id="theSearchForm" name="theSearchForm" role="search" method="get" action="yoursearchfilescriptgoeshere">
                    <div class="input-group">
                        <input type="text" class="form-control" placeholder="Search">
                        <div class="input-group-btn">
                            <a class="btn btn-default" href="javascript:document.theSearchForm.submit();"><i class="glyphicon glyphicon-search"></i></a>

                        </div>

1 个答案:

答案 0 :(得分:1)

是的,你可以找到工作的fiddel:https://jsfiddle.net/ywxm8rtr/

$(".autocomplete").autocomplete({
    source: availableTags
  });