javascript - Bootstrap-select displays two selects menus - Stack Overflow

ObjectiveTo implement styling on the select tag using the Bootstrap-select library. ProblemI am getting

Objective

To implement styling on the select tag using the Bootstrap-select library.

Problem

I am getting two selects rather than just one dropdown menu.

Question

What do i need to change in my javascript or elsewhere to get it to display correctly

Code

Demo on CodePen

HTML

<select class="selectpicker">
    <option data-hidden="true">Choose one...</option>
    <option>BBQ Pork</option>
    <option>Bacon</option>
    <option>Sausage</option>
</select>

Script library order

  • //cdnjs.cloudflare/ajax/libs/jquery/2.1.3/jquery.min.js
  • .3.5/js/bootstrap.min.js
  • .7.5/js/bootstrap-select.min.js

Javascript (I placed it in a script tag after the libraries)

$(document).ready(function(){
    $('.selectpicker').selectpicker(); 
});

Objective

To implement styling on the select tag using the Bootstrap-select library.

Problem

I am getting two selects rather than just one dropdown menu.

Question

What do i need to change in my javascript or elsewhere to get it to display correctly

Code

Demo on CodePen

HTML

<select class="selectpicker">
    <option data-hidden="true">Choose one...</option>
    <option>BBQ Pork</option>
    <option>Bacon</option>
    <option>Sausage</option>
</select>

Script library order

  • //cdnjs.cloudflare./ajax/libs/jquery/2.1.3/jquery.min.js
  • https://cdnjs.cloudflare./ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js
  • https://cdnjs.cloudflare./ajax/libs/bootstrap-select/1.7.5/js/bootstrap-select.min.js

Javascript (I placed it in a script tag after the libraries)

$(document).ready(function(){
    $('.selectpicker').selectpicker(); 
});
Share Improve this question edited Nov 5, 2015 at 23:29 JGallardo asked Nov 5, 2015 at 23:04 JGallardoJGallardo 11.4k12 gold badges87 silver badges99 bronze badges 3
  • 1 You havent added the CSS file for Bootstrap-Select – vanburen Commented Nov 5, 2015 at 23:09
  • 2 @vanburen yes, i missed that. I am tempted to delete the question but since it might help someone later, I would like to leave it up. If you would like to add that as an answer I will accept it. Otherwise I will answer my own question with the input you gave. Thanks. – JGallardo Commented Nov 5, 2015 at 23:25
  • Thanks and glad I could help. – vanburen Commented Nov 5, 2015 at 23:28
Add a ment  | 

1 Answer 1

Reset to default 6

You just need to add the Bootstrap-select CSS file.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745533127a4631784.html

相关推荐

  • javascript - Bootstrap-select displays two selects menus - Stack Overflow

    ObjectiveTo implement styling on the select tag using the Bootstrap-select library. ProblemI am getting

    9小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信