Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const selectHTML = document.getElementById("cities");
- let prevValue = null;
- selectHTML.addEventListener("change", () => {
- if(prevValue !== null) {
- console.log(selectHTML.children[prevValue]);
- selectHTML.children[prevValue].removeAttribute("selected");
- }
- val = selectHTML.value - 1;
- selectHTML.children[val].setAttribute("selected", "");
- prevValue = val;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement