获取Jquery上的下拉菜单值
我有一个简单的问题。我想得到一个下拉菜单值时,使用点击它。我试着自己写代码,但做不到。任何帮助都将不胜感激 我的Jquery获取Jquery上的下拉菜单值,jquery,html,forms,Jquery,Html,Forms,我有一个简单的问题。我想得到一个下拉菜单值时,使用点击它。我试着自己写代码,但做不到。任何帮助都将不胜感激 我的Jquery $("#week").change(function(){ var input=$("week: select").val(); alert(input); //display undefiend 我的Html <form id="week"> <select> <option>Week
$("#week").change(function(){
var input=$("week: select").val();
alert(input); //display undefiend
我的Html
<form id="week">
<select>
<option>Week 1</option>
<option>Week 2</option>
<option>Week 3</option>
<option>Week 4</option>
<option>Week 5</option>
</select>
</form>
第一周
第2周
第3周
第4周
第5周
执行以下操作:
$("#week select").change(function(){
var input = $(this).val();
alert(input);
});
这样做:
$("#week select").change(function(){
var input = $(this).val();
alert(input);
});
@Kobi-select是#week
的子项,其代码正确。@Kobi-select是#week
的子项,其代码正确。