A brief discussion on drop-down menu events in Bootstrap3

青灯夜游
Release: 2021-03-25 10:55:37
forward
2200 people have browsed it

This article takes you through the events of the Bootstrap3 drop-down menu. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

A brief discussion on drop-down menu events in Bootstrap3

Events of the drop-down menu

Bootstrap provides 4 events for the drop-down menu plug-in. By listening to these events, you can control specific Respond to user actions during the operation phase. These events and their meanings are shown in Table 4‑3.

Table 4‑3 Events and meanings of dropdown plug-in
Event Meaning
show.bs.dropdown After the show method is called, this event is triggered immediately
shown.bs.dropdown This event is triggered when the drop-down menu is visible to the user (and the transition effect is completed)
hide.bs.dropdown After the hide method is called, this event is triggered immediately Event
hidden.bs.dropdown This event is triggered after the drop-down menu has been hidden (and the transition effect is completed)

Related recommendations: "bootstrap Tutorial"

If developers want to customize the functions of the drop-down menu, they can listen to these events through JavaScript to perform corresponding operations. Such as:

<script>
  $(&#39;#myDropdown&#39;).on(&#39;show.bs.dropdown&#39;, function () {
   alert("开始显示下拉菜单。");
  });
  $(&#39;#myDropdown&#39;).on(&#39;shown.bs.dropdown&#39;, function () {
     alert("下拉菜单已经显示。");
  });
  $(&#39;#myDropdown&#39;).on(&#39;hide.bs.dropdown&#39;, function () {
     alert("开始隐藏下拉菜单。");
  });
  $(&#39;#myDropdown&#39;).on(&#39;hidden.bs.dropdown&#39;, function () {
     alert("下拉菜单已经隐藏。");
  });
</script>
Copy after login

For more programming-related knowledge, please visit: Programming Video! !

The above is the detailed content of A brief discussion on drop-down menu events in Bootstrap3. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template