By doing some code inspection, it looks like select2-dropdown-open
is the class that it adds. But there is an event select2-open
in the documentation that fires when the dropdown is open. You can use that to set a variable, or perform an action (also select2-close
).
You can do something like this:
$("#e11").on("select2-open", function() {
$(this).data("open", true);
});
$("#e11").on("select2-close", function() {
$(this).data("open", false);
});
if ($("#e11").data("open")) {
//do something
}
2018 Edit
It appears that the names of the events have been updated since 2014. See user1636505's answer below.