Bootstrap Dropdown获取所选项目的值 [英] Bootstrap Dropdown get value of selected item

查看:296
本文介绍了Bootstrap Dropdown获取所选项目的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Bootstrap下拉切换按钮,有什么方法可以显示刚刚选择的值?

With the Bootstrap dropdown-toggle buttons is there any way to show the value that has just been selected?

<form action="/output/" name="InputCacheCheck" method="post">
{% csrf_token %}
    <div class="input-prepend input-append">
        <div class="btn-group">

            <button class="btn dropdown-toggle" name="recordinput" data-toggle="dropdown">
            Record
            <span class="caret"></span>
            </button>
            <ul class="dropdown-menu">
                  <li><a href="#">A</a></li>
                  <li><a href="#">CNAME</a></li>
                  <li><a href="#">MX</a></li>
                  <li><a href="#">PTR</a></li>
            </ul>
        <input class=".input-large" name="hostnameinput" id="appendedInputButton" type="text">
        <button class="btn" type="submit">Lookup</button>
        </div>
    </div>
</form>

在表单POST数据中也没有提供recordinput名称. 有什么想法吗?

Also the name recordinput isn't being supplied within the forms POST data. Any ideas?

推荐答案

您应该能够像这样更改下拉文本.

You should be able to change the dropdown text like this..

$(".dropdown-menu li a").click(function(){
  var selText = $(this).text();
  $(this).parents('.btn-group').find('.dropdown-toggle').html(selText+' <span class="caret"></span>');
});

演示 http://www.bootply.com/64302

Demo http://www.bootply.com/64302

如何对表单进行发布"?

How is the form being 'POST'ed?

这篇关于Bootstrap Dropdown获取所选项目的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆