I want to add a background overlay on my webpage to darken the website when a selectbox is opened.
This needs to be triggered when the select is opened I tried using onClick but that doesn't work. onChange only works if there is something selected other than the dfault value but this is not what I want. I want it to trigger whenever the select is clicked.

Nvm, I use select2 and I found it in their documentation:
select2:close Triggered whenever the dropdown is closed. select2:closing is fired before this and can be prevented.
select2:open Triggered whenever the dropdown is opened. select2:opening is fired before this and can be prevented.
Select 2 code used:
Overlay beeing the div that darkens the website.