user2782692
user2782692

Reputation: 109

handling dropdown item selected event using Bootstrap

Hi I have just started using twitter bootstrap and trying my hand on handling dropdown events.

I want to handle the dropdown item selected event, that is, when the user clicks on a particular item, a table should be displayed just below the dropdown. Can anyone please help me out in achieving this? Thank you.

<ul class="dropdown-menu">
    <!-- dropdown menu links -->
    <li><a href="#" id="action-1">How are you?</a></li>
    <li><a href="#2">What is your name</a></li>
    <li><a href="#section-2">Section 2</a></li>
</ul>

Upvotes: 11

Views: 28159

Answers (2)

guymac
guymac

Reputation: 406

You can handle the function in the menu itself, e.g.

<li><a href="javascript:itemSelected('A')">A. Hello World!</a></li>

Upvotes: 0

omma2289
omma2289

Reputation: 54619

There's no such event in Bootstrap, the only events you can handle for dropdowns are show, shown, hide, hidden, you can use simple jQuery for this though:

$('.dropdown-menu a').click(function(){
    //Show table
});

Upvotes: 18

Related Questions