country-select-js
country-select-js copied to clipboard
How to make country-select-js readonly?
I would like to know how to make the country-select-js library readonly. Currently, I'm using the library for a country selection feature, but I want to prevent users from modifying the selected country. Is there a way to achieve this functionality with country-select-js? I would appreciate any guidance or code examples on how to implement the readonly behavior.
The solution I have currently
var element = document.querySelector(".country-list.hide");
element.remove();
Not sure if that helps here, but I use the readonly attribute on the input field and style the background with the :read-only pseudo-class.
I haven't figured out, however, how to open the menu. Just removing the "hide" class doesn't add the event listeners to the menu items. Triggering a click event on the .selected-flag
div opens it for a short time and closes it immediately.