With native js, you can construct an explicit and implicit function, and then traverse to each btn. The explicit and implicit function can change the height of the ul through the transition of CSS3, or change the display and opacity. The specifics must be determined according to the actual situation. To make it simpler, you can use fade and slide in jQuery.
With native js, you can construct an explicit and implicit function, and then traverse to each btn. The explicit and implicit function can change the height of the ul through the transition of CSS3, or change the display and opacity. The specifics must be determined according to the actual situation. To make it simpler, you can use fade and slide in jQuery.
This is an XY problem
The purpose is not to get the element index, but to bind similar event processing to similar elements
Add a special class for all buttons to which events will be bound
Just select these elements and bind them through the class
Add the same class="btn bt1" class="btn bt2" class="btn bt3" to each button
$('.btn').click(function(){
$(".btunder").hide();
})