0
A
回答
3
var selectedValue = $('select#id_of_your_select').val();
0
讓我們假設這個HTML代碼:
<form id ='formId'>
<select id='selectBox' name='selectBox'>
<option value='1'>option 1</option>
<option value='2'>option 2</option>
</select>
<input type='button' value='go' id='goButton' />
jQuery代碼將是這樣的:
$(document).ready(function(){
$("#formId").submit(function(){
return false; // disable the regular submit
});
$("#goButton").click(function(){
var desiredValue = $("#selectBox").val();
alert(desiredValue);
});
});
另一種方式是檢測的變化,因爲它發生:
$(document).ready(function(){
$("#selectBox").change(function(){
var desiredValue = $(this).val();
alert(desiredValue);
});
});
相關問題
- 1. 使用jQuery解析RadDropDownList中的'selectedValue'
- 2. DropDownlList的SelectedValue
- 3. Combobox selectedvalue
- 4. Html.DropDownlistFor selectedValue
- 5. Html.DropDownList SelectedValue
- 6. dropdownlist selectedvalue
- 7. SelectedItem和SelectedValue返回錯誤的項目
- 8. 的SelectList ingoring的SelectedValue
- 9. ASP:NET - GridView的 - DropDownList selectedvalue
- 10. 組合框的SelectedValue
- 11. WPF中的ListView SelectedValue
- 12. DropDownList的SelectedValue與SelectedItem.Value
- 13. C#的SelectedValue在ListBox
- 14. 設置GridDropDownColumn的SelectedValue
- 15. Jlist selectedValue爲null
- 16. ExtJs Combo selectedValue
- 17. DataComboBox SelectedValue屬性
- 18. Dropdownlist重置SelectedValue
- 19. DropDownList selectedvalue and tables
- 20. ComboBox SelectedItem vs SelectedValue
- 21. MVC3 DropDownlistFor SelectedValue
- 22. combobox databinding selectedvalue event
- 23. 實時DropdownList SelectedValue
- 24. DropDownList1.SelectedValue爲空?
- 25. Silverlight AutoCompleteBox SelectedValue(?)
- 26. Get DataGridViewComboboxColumn SelectedValue(VB.Net)
- 27. DropdownList獲取SelectedValue
- 28. ComboBox selectedValue/Item
- 29. JQuery的數據綁定在改變的SelectedValue ASP.NET的DropDownList
- 30. 的DropDownList的SelectedValue不工作