-1

All Bootstrap Dropdown menu examples show the items having an link like:

    <li><a href="#">a</a></li>

How can I make a Bootstrap dropdown menu where choosing an item triggers a javascript method?

(If it makes a difference, the menu items will also be added to the menu using javascript/jquery initially)

Is this just a matter of adding a click function to each <li>? Or does Bootstrap provide special handling for its dropdown items?

If I add a click function, do I still need each item to also have the <a href="#"> tag around the text?

PurpleVermont
  • 1,019
  • 4
  • 15
  • 40

1 Answers1

1

Looks like the answer is:

  • Bootstrap does not supply any special handling for clicks on its dropdown menu items; and
  • I could add a click function to each item in the list; or

  • I could use event delegation to add the click function to the list
    itself, and it will be triggered on each child's click

Thanks to @Pevara and @spaceman for getting me rolling.

Community
  • 1
  • 1
PurpleVermont
  • 1,019
  • 4
  • 15
  • 40