xxxxxxxxxx
1
<div>
2
3
</div>
4
<div class="dropdown" id="gdd">
5
<button
6
class="btn btn-primary dropdown-toggle"
7
type="button"
8
id="dropdownMenuButton"
9
data-mdb-toggle="dropdown"
10
data-mdb-auto-close="true"
11
aria-expanded="false"
12
>
13
Dropdown button
14
</button>
15
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton">
16
<li><a class="dropdown-item" href="#">Action</a></li>
17
<li><a class="dropdown-item" href="#">Another action</a></li>
18
<li><a class="dropdown-item" href="#">Something else here</a></li>
19
</ul>
20
</div>
21
22
23
<br><br><br><br><br><br><br><br><br><br><br><br>
24
<button onclick="openDrop()">Open</button>
25
26
27
1
1
xxxxxxxxxx
1
//const myDropdown = document.getElementById('myDropdown');
2
//const myDropdownInstance = new mdb.Dropdown(myDropdown);
3
//myDropdownInstance.show();
4
5
function openDrop() {
6
console.log('Button clicked');
7
const myB = document.getElementById("dropdownMenuButton");
8
const myDD = new mdb.Dropdown(myB);
9
console.log(myDD._isShown());
10
setTimeout( ()=> {
11
myDD.show();
12
}, 0)
13
14
console.log(myDD._isShown());
15
console.log(myDD._config["autoClose"]);
16
// console.log(myDD._config.offset[0]);
17
// myDD._config["autoClose"]=true;
18
};
19
20
21
Console errors: 0