select_event_remove_on_change.html   [plain text]


<!DOCTYPE html>
<html>
<body>
<div id="message"></div>
<select id="s" autofocus>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<script>
function handler(e) {
  document.getElementById('message').innerText += "change";
  select = document.getElementById('s');
  select.parentNode.removeChild(select);
}

document.getElementById('s').addEventListener('change', handler);
</script>
</body>
</html>