I have a dropdown menu and I want to call a function, when the dropdown menu ITSELF is clicked. I mean the part where you click on the dropdown menu <select> and all the available <options> are displayed.
<select id="p1" title="Select a thing" class="selectpicker show-tick" data-live-search="true">
<option data-hidden="true"></option>
<option>Select A</option>
<option>Select B</option>
</select>
If I want to do something when Select A has been selected, I have the following.
$('#p1').change(function(event) {
console.log("You selected an option");
});
But how to trigger something if the dropdown menu itself is clicked? I would like to load the <option> with data when the dropdown menu itself is clicked.
The following is not working:
$("#p1").click(function(){
console.log("Loading <options>");
});
EDIT:
I found the problem. It is because I use a plugin called bootstrap-select https://silviomoreto.github.io/bootstrap-select/
If I remove class="selectpicker show-tick" data-live-search="true" it works!
But how do I get on click working with the bootstrap-select plugin?