I'm trying to make the JavaScript for a <select>'s <option> with 2 items inside it, but I don't seem to be able to do any events once one of them are selected. Here's my code:
var e1 = document.getElementById("#selector").option[0].text;
var e2 = document.getElementById("#selector").option[1].text;
var e3 = document.getElementById("#selector").option[2].text;
document.querySelector("e1").addEventListener("click", myInfo, false);
function myInfo(){
alert("Test");
}
<select id="selector">
<option value="" disabled="disabled" selected="selected">Select a layout</option>
<option value="1">One</option>
<option value="2">Two</option>
</select>
document.querySelector("e1")is looking for an element<e1>, whereas you're probably - or should be - looking to find the<select>element, with eitherdocument.getElementById('selector');ordocument.querySelector('#selector')