[英]MVC4 Bootstrap JQuery - Set Dropdown title to item selected
I've been following several posts on here about returning the value selected from a drop-down list and setting the title of the drop-down to this selection. 我在这里关注了几篇有关返回从下拉列表中选择的值并将下拉菜单的标题设置为该选择的文章。 current: How to change the main display of dropdown when an item is selected in bootstrap
当前: 在引导程序中选择项目时如何更改下拉菜单的主显示
Ive tried several other examples but none are working for me when other scripts work fine. 我已经尝试了其他几个示例,但是当其他脚本正常工作时,没有一个对我有用。
Can anyone see my silly error? 谁能看到我的愚蠢错误? (I know it has to be something small)
(我知道它一定很小)
My Dropdown: 我的下拉菜单:
<div class="form-group">
<label for="platform" class="control-label col-xs-2">Platform:</label>
<div class="col-xs-10">
<div class="dropdown">
<button class="btn btn-default" id="pickButton" data-toggle="dropdown">
<span id="dropdown_title">Select</span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" id="selectionDropdown">
<li><a tabindex="-1" href="#">Android</a></li>
<li><a tabindex="-1" href="#">IOS</a></li>
<li><a tabindex="-1" href="#">Windows Phone</a></li>
</ul>
</div>
</div>
</div>
My Script: 我的剧本:
<script>
$(document).ready(function () {
$('#pickButton').dropdown();
$('#selectionDropdown li').on('click', function() {
$('#dropdown_title').html($(this).find('a').html());
});
});
</script>
由于没有答案,代码似乎已经修复了自己(归咎于VS2013),请参阅问题以获取工作代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.