简体   繁体   English

MVC4 Bootstrap JQuery-将下拉标题设置为所选项目

[英]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.

相关问题 已选择AngularJs Bootstrap set下拉项 - AngularJs Bootstrap set dropdown item selected 如何使用Jquery更改Bootstrap下拉所选项目? - How to change Bootstrap dropdown selected item with Jquery? Bootstrap JQuery:对所选项目的下拉菜单验证 - Bootstrap JQuery: dropdown menu validation on selected item 如何在Angular中的Bootstrap下拉标题上显示所选项? - How to display the selected Item on Bootstrap Dropdown Title in Angular? 如何在Bootstrap下拉标题中显示带有图标的所选项目? - How to display selected item with icons in Bootstrap dropdown title? Bootstrap Dropdown选定的项目 - Bootstrap Dropdown selected item 如何在引导程序下拉列表的标题中显示所选项目? 以及如何在JavaScript警报框中显示所选项目? - How to display selected item in the title of the bootstrap dropdown list ? and how to display selected item on a javascript alert box? 根据下拉列表选择值从数据库中获取下拉选择值到两个文本框,IDIN MVC4 jQuery - Get dropdown selected value to two textbox from database based on dropdown list selected value idin mvc4 jquery Bootstrap下拉列表中的选定项目 - Selected item on Bootstrap dropdown list jQuery / Bootstrap:下拉切换未将所选菜单项设置为默认所选项 - jQuery/Bootstrap : dropdown-toggle is not setting the selected menu item as default selected item
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM