var checkText = $("#select_id").find("option:selected").text();
var checkValue = $("#select_id").val();
var checkIndex = $("#select_id").get(0).selectedIndex;
$("#select_id").get(0).selectedIndex = 1;
$("#select_id").val(4);
$("#select_id option").filter(function () {
return $(this).text() === "jQuery";
}).attr("selected", true);
$("#select_id").append('<option value="Value">Text</option>');
$("#select_id").prepend('<option value="0">請選擇</option>');
$("#select_id option:last").remove();
$("#select_id option[value='3']").remove();
文字框與文字區域可用 val() 或 attr("value");核取方塊與單選鈕可透過 checked 屬性或 :checked 選擇器取值。下拉選單常用 val() 取得目前值,option:selected 則可取得文字。
在 jQuery 1.3 之後,部分舊式 @ 寫法已不建議使用,例如 input[@checked] 可改為 input:checked,以提升相容性與可讀性。