我有一个像这样的表单:
我希望能够使用jquery获取所选国家的值。
这是我的jquery代码,我的jquery版本是jquery-1.10.1.js。
我不喜欢通过ID或class来调用选择器。提前感谢。
我无法为国家选择框编写onChange事件。 我需要在日期输入字段(followup_date)模糊时执行ajax请求。
<label>Select country</label>
<select name="country">
<option value="IND" selected="selected">India</option>
<option value="MY">Malaysia</option>
<option value="US">United states</option>
</select>
</label>
我希望能够使用jquery获取所选国家的值。
这是我的jquery代码,我的jquery版本是jquery-1.10.1.js。
alert($('select[name="country"]').find(":selected").val());
alert($('select[name="country"] option:selected').val());
我不喜欢通过ID或class来调用选择器。提前感谢。
我无法为国家选择框编写onChange事件。 我需要在日期输入字段(followup_date)模糊时执行ajax请求。
$('#followup_date').change(function(e) {
if($(this).val()!='')
{
//$('.tmslot').not(this).attr('checked', false);
var slot = $(this).val();
var country_id = $('select[name="country"] option:selected').val();
我的问题是我得到了 undefined 作为 country_id 的值。
alert($('select[name="country"]').val());
应该没问题 - http://jsfiddle.net/arunpjohny/sof2pjbs/2/ - Arun P Johny$('select[name="country"]').find(":selected").val();
- mgamon