How do you attach an event handler to a Bootstrap dropdown menu?
- $('dropdown').click(function() {...})
- $('dropdown').on('click', function() {...})
- $('dropdown').addEventListener('click', function() {...})
- $('dropdown').dropdown('toggle')
The correct answer is $('dropdown').on('click', function() {...}). This method is used to attach an event handler to a Bootstrap dropdown menu using jQuery. It allows you to define actions when the dropdown is clicked, providing a way to customize the dropdown's behavior.
Loading...
Related Quiz
- Describe a strategy for optimizing the performance of a Bootstrap project when integrating multiple third-party JS libraries.
- What is the jQuery method used for programmatically opening a Bootstrap dropdown?
- Discuss the impact of modifying Bootstrap's $spacer variable on layout and spacing.
- Discuss the impact of jQuery's .on() method on the event handling of Bootstrap components.
- In a web application requiring dynamic modal dialogs, how would Bootstrap JS enhance the modals beyond the capabilities of Bootstrap CSS?