F
F
FlexibleCurd2015-10-06 12:30:48
JavaScript
FlexibleCurd, 2015-10-06 12:30:48

How to get value in option when selected, via jquery?

<select id="selectYear">
<option>Все</option>
<option>1999</option>
<option>2000</option>
<option>2001</option>
<option>2002</option>
</select>


I’ll clarify: how to make it so that when you click on an option, an alert appears with the text from the option.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DevMan, 2015-10-06
@FlexibleCurd

$('#selectYear').change(function() {
    alert(this.value);
});
jsfiddle.net/6swukaw6

R
Rikcon, 2015-10-06
@Rikcon

$('#selectYear:selected').val();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question