Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the main display of dropdown when an item is selected in bootstrap

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?

like image 355
coderslay Avatar asked Dec 16 '22 15:12

coderslay


1 Answers

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.

like image 163
Elliot B. Avatar answered Feb 15 '23 23:02

Elliot B.