Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8875531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:59:45+00:00 2026-06-14T18:59:45+00:00

I am using the bootstrap Dropdown component in my application like this: <div class=btn-group>

  • 0

I am using the bootstrap Dropdown component in my application like this:

<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>

I would like to display the selected item as the btn label. In other words, replace “Please Select From List” with the list item that has been selected(“Item I”, “Item II”, “Item III”).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:59:46+00:00Added an answer on June 14, 2026 at 6:59 pm

    As far as i understood your issue is that you want to change the text of the button with the clicking linked text, if so you can try this one: http://jsbin.com/owuyix/4/edit

     $(function(){
    
        $(".dropdown-menu li a").click(function(){
    
          $(".btn:first-child").text($(this).text());
          $(".btn:first-child").val($(this).text());
    
       });
    
    });
    

    As per your comment:

    this doesn’t work for me when I have lists item <li> populated through ajax call.

    so you have to delegate the event to the closest static parent with .on() jQuery method:

     $(function(){
    
        $(".dropdown-menu").on('click', 'li a', function(){
          $(".btn:first-child").text($(this).text());
          $(".btn:first-child").val($(this).text());
       });
    
    });
    

    Here event is delegated to static parent $(".dropdown-menu"), although you can delegate the event to the $(document) too because it is always available.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using twitter bootstrap. Here is my code: <div class=control-label> We <div class=btn-group>
I'm using Twitter Bootstrap and I want to make dropdown look like this: and
I am using the Bootstrap CSS framework that has this: .dropdown-menu { left: 0;
I'm using twitter bootstrap. It has collapse module. I'm using it like this. <a
I would like to open a dropdown menu (using Twitter Bootstrap) everytime I click
I am using using bootstrap-dropdown to generate a Dropdown menu. I would like to
I am using bootstrap-dropdown to generate a Dropdown menu. I would like to disable
I'm using twitter bootstrap. I'm trying to create a button with dropdown that should
I have a question with Twitter Bootstrap, I'm using the Dropdown plugin and I'm
I am using bootstrap with a theme from bootswatch with html5 boiler plate to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.