Answer the question
In order to leave comments, you need to log in
Why do I only see README.md after cloning a git repository?
I am not familiar with the guide at all, I will be grateful for the help)
Answer the question
In order to leave comments, you need to log in
<select onchange='findOption(this)'>
<option value='one'>1</option>
<option value='two'>2</option>
<option value='three'>3</option>
</select>
function findOption(select) {
const option = select.querySelector(`option[value="${select.value}"]`)
// Действия над option
}
Each option tag must have a value attribute. The value of the active option is automatically passed to the upstream select tag, where it can be obtained by accessing the value property directly.
UPD. The user's selection of an option generates two events: input and change.
var select = document.querySelector('select');
select.addEventListener('change', () => {
alert(select.value);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question