linked bootstrap.min.css, bootstrap-theme.min.css, jquery.min.js", bootstrap.js,dropdown.js
链接bootstrap.min.css,bootstrap-theme.min.css,jquery.min.js“,bootstrap.js,dropdown.js
http://jsfiddle.net/id10922606/54edxsmv/1/
<script type="text/javascript">
$(document).ready(function(){
$('.dropdown-toggle').dropdown()
});
</script>
<div class="btn-group">
<button type="button" class="btn btn-danger">Action</button>
<button type="button" class="btn btn-danger dropdown-toggle" data- toggle="dropdown" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
Why selected item not loading instead of 'Action' list value. only working dropdown menu ? please help
为什么选择的项目不加载而不是'Action'列表值。只有工作下拉菜单?请帮忙
1 个解决方案
#1
You need to make sure your fiddle includes the links / references to external resources.
您需要确保您的小提琴包含外部资源的链接/引用。
When you say "Why selected item not loading instead of 'Action' list value", do you mean it's not updating the dropdown with the item you click on? If so, you want to add the following:
当您说“为什么选择的项目没有加载而不是'行动'列表值”时,您是说它没有使用您点击的项目更新下拉列表吗?如果是这样,您要添加以下内容:
$(document).ready(function(){
$('.dropdown-toggle').dropdown();
$('.dropdown-menu li a').click(function() {
$('.btn:first-child').text($(this).text());
$('.btn:first-child').val($(this).text());
});
});
http://jsfiddle.net/54edxsmv/4/
What this does, is when you click on an li a
tag within the .dropdown-menu
list, it will update the text and value of the first button .btn:first-child
with the clicked items text.
这样做的是,当您单击.dropdown菜单列表中的li标签时,它将更新第一个按钮的文本和值.btn:带有单击项目文本的first-child。
There are many ways of handling multiple dropdowns, for example:
有多种方法可以处理多个下拉列表,例如:
$(document).ready(function(){
$('.dropdown-toggle').dropdown();
$.each($('.btn-group'), function() {
var $dropdown = $(this);
$dropdown.find('.dropdown-menu li a').click(function() {
$dropdown.find('.btn:first-child').text($(this).text());
$dropdown.find('.btn:first-child').val($(this).text());
});
});
});
#1
You need to make sure your fiddle includes the links / references to external resources.
您需要确保您的小提琴包含外部资源的链接/引用。
When you say "Why selected item not loading instead of 'Action' list value", do you mean it's not updating the dropdown with the item you click on? If so, you want to add the following:
当您说“为什么选择的项目没有加载而不是'行动'列表值”时,您是说它没有使用您点击的项目更新下拉列表吗?如果是这样,您要添加以下内容:
$(document).ready(function(){
$('.dropdown-toggle').dropdown();
$('.dropdown-menu li a').click(function() {
$('.btn:first-child').text($(this).text());
$('.btn:first-child').val($(this).text());
});
});
http://jsfiddle.net/54edxsmv/4/
What this does, is when you click on an li a
tag within the .dropdown-menu
list, it will update the text and value of the first button .btn:first-child
with the clicked items text.
这样做的是,当您单击.dropdown菜单列表中的li标签时,它将更新第一个按钮的文本和值.btn:带有单击项目文本的first-child。
There are many ways of handling multiple dropdowns, for example:
有多种方法可以处理多个下拉列表,例如:
$(document).ready(function(){
$('.dropdown-toggle').dropdown();
$.each($('.btn-group'), function() {
var $dropdown = $(this);
$dropdown.find('.dropdown-menu li a').click(function() {
$dropdown.find('.btn:first-child').text($(this).text());
$dropdown.find('.btn:first-child').val($(this).text());
});
});
});