I am facing an issue with accessing multiple select elements that have the same options in Javascript. Despite having the same class, I am unable to retrieve the options using Javascript. When I attempted switching from getElementById to getElementsByClassName, it did not yield any results. As someone who is relatively new to Javascript, I struggle to comprehend the differences between these two methods.
Here is the code snippet:
<select class="phoneNumber"></select>
<script>
phoneNumber = document.getElementById("phoneNumber");
var option1 = document.createElement('option'); option1.text = '1234567897'; phoneNumber.appendChild(option1);
var option2 = document.createElement('option'); option2.text = '1233213211'; phoneNumber.appendChild(option2);
</script>