我有一個性別單選按鈕和下拉的課程,得到遏制單選按鈕,使用jQuery
選擇下拉顯示值我有jQuery的動態值。
如何獲取Gender和Courses中的選定選項。
這裏是我的Fiddle Demo
我提供我的代碼在這裏太:
HTML:
Male <input type="radio" name="gender" id="male" value="1"> -
Female <input type="radio" name="gender" id="female" value="2">
<br>
<select name="courses" id="courses">
<option value="0">Choose Courses</option>
<option value="1">PHP</option>
<option value="2">Jquery</option>
<option value="3">HTML</option>
</select>
JS:
$(function() {
//these are the values I got, these values are dynamic
var gender = 2;
var course = 3;
}
Prop是一個新功能。我使用Jquwey的lod庫,道具的替代品是什麼?你可以做出來支柱 –
'attr'是'prop'的替代品。我更新了我的答案,查看演示。 – super