I need to get a current value of SELECT tag. And for this I’m using $('select').val(), but this return only default value and it’s don’t changed. May be I can help me?
$('div#buy input').fancybox({
ajax : {
type : "POST",
data : {
id: $('input[name="id"]').val(),
count: $('#count').val()
}
}
});
<select id="count">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
In jQuery,
$('#count').val()will give the currently selected value for the<select>element with id “count”. I suspect that your code sample is running before the user has made a selection, and that’s why you’re getting the default value. You should set yourcountproperty sometime after the user has made a selection. Something like this will work:This way, the options object will get updated when the selection is changed.