在引导程序中选择项目时如何更改下拉列表的主显示 [英] How to change the main display of dropdown when an item is selected in bootstrap
问题描述
这是下面的http://jsfiddle.net/coderslay/enzDx/
我正在尝试在点击项目后立即更改文本选择
因此,如果我从列表中选择 One
,则应该显示 One
.
怎么做?
工作示例:http://jsfiddle.net/enzDx/5/
我对您的 HTML 所做的唯一更改是将带有 span
标签的文本Select"与元素 ID dropdown_title
包裹起来,以便更容易更新.>
JavaScript:
$('.dropdown-toggle').dropdown();$('#divNewNotifications li').on('click', function() {$('#dropdown_title').html($(this).find('a').html());});
基本上我所做的就是每当用户单击列表项时,我都会使用最后一项中包含的链接文本更新下拉标题文本.
This is the following 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.
How to do it?
Working example: http://jsfiddle.net/enzDx/5/
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:
$('.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屋!