Depends. It looks as though you’re trying to use jQuery (the JavaScript code contains $(...) which usually indicates jQuery). So first, please confirm jQuery is present on the page.
How to Verify jQuery Present
Bring up the Browser DevTools Console[1] and type this in the console and hit ENTER:
jQuery
You should see something like this:
Let me know what you find.
Either way, please post a screenshot of the HTML used to construct the dropdown.