在引导中选择项目时,如何更改下拉列表的主显示
这是以下 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.