jQueryでSELECT'の値とテキストを取得する

セレクトボックスの場合、jQueryで選択された項目の値とテキストを取得するにはどうしたらいいですか?

例えば、以下のようになります。

<option value="value">text</option>
ソリューション

<select id="ddlViewBy">
    text
解説 (1)
$('select').val()  // Get's the value

$('select option:selected').val() ; // Get's the value

$('select').find('option:selected').val() ; // Get's the value

$('select option:selected').text()  // Gets you the text of the selected option

[チェックFIDDLE][1]の場合

解説 (0)

唯一のjQueryタグを基にして :)

HTML)


<select id="my-select">
This is text 1
This is text 2
This is text 3
解説 (0)