在引导中选择项目时,如何更改下拉列表的主显示 [英] How to change the main display of dropdown when an item is selected in bootstrap

查看:131
本文介绍了在引导中选择项目时,如何更改下拉列表的主显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是以下 http://jsfiddle.net/coderslay/enzDx/

只要点击一个项目,我正在尝试更改文本选择

I am trying to change the text Select as soon as an item is clicked

所以如果我从列表中选择一个,则应显示一个

So if i select One from the list then One should be displayed.

如何做?

推荐答案

工作示例: http://jsfiddle.net/enzDx/5/

Working example: http://jsfiddle.net/enzDx/5/

我所做的唯一改变您的HTML将元素ID dropdown_title span 标签包含文本选择,以便更新更容易

The only change I made to your HTML was to wrap the text "Select" with span tags with the element ID dropdown_title so it was easier to update.

JavaScript:

JavaScript:

$('.dropdown-toggle').dropdown();
$('#divNewNotifications li').on('click', function() {
    $('#dropdown_title').html($(this).find('a').html());
});​

基本上我所做的是每当用户单击列表项,我将使用最后一个项目中包含的链接文本更新下拉标题文本。

Basically all I'm doing is whenever the user clicks on a list item, I update the drop-down title text with the text of the link contained in the last item.

这篇关于在引导中选择项目时,如何更改下拉列表的主显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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