How to Display Selected Item in Bootstrap Button Dropdown Title
Hi
I am using the bootstrap Dropdown component at my application and it is like:
- <div class="btn-group">
- <button class="btn">Please Select From List</button>
- <button class="btn dropdown-toggle" data-toggle="dropdown">
- <span class="caret"></span>
- </button>
- <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu">
- <li><a tabindex="-1" href="#">Item I</a></li>
- <li><a tabindex="-1" href="#">Item II</a></li>
- <li><a tabindex="-1" href="#">Item III</a></li>
- <li class="divider"></li>
- <li><a tabindex="-1" href="#">Other</a></li>
- </ul>
- </div>
Now I would like to display the selected item as the btn caption.As you can see it is hard coded by "Please Select From List" but how I can display selected Item instead of that in the btn using jquery? I know that I can change that title by using the .html() or .text() method but I do not know how to grab selected value from the list? Can you please help me to figure this out? Thanks for your help