選択ボックスの値を取得するときに :selected を呼び出す必要はありません。
デフォルトの動作は、selectedIndex を取得することです。
$( "#institutionCombo").val();
コメントに記載されているように、そのオプションのテキストにアクセスする必要がある場合は、使用できます
$( "#institutionCombo option[value=" + $( "#institutionCombo").val(); + "]").text();
ただし、テキスト プロパティが必要であり、値とは異なることがわかっている場合は、selectedIndex を直接使用することもできます。
var combo = $("#institutionCombo").get(0);
combo = combo ? combo : {selectedIndex: -1}; // handle no combo returned
if (combo.selectedIndex < 0)
return; // nothing selected
$('#institutionCombo option:eq(' + combo.selectedIndex + ')').text()
jquery ソース (v1.3) のスニペットを次に示します。
val: function( value ) {
// ...
// We need to handle select boxes special
if ( jQuery.nodeName( elem, "select" ) ) {
var index = elem.selectedIndex,
values = [],
options = elem.options,
one = elem.type == "select-one";
// Nothing was selected
if ( index < 0 )
return null;
// Loop through all the selected options
for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
var option = options[ i ];
if ( option.selected ) {
// Get the specifc value for the option
value = jQuery(option).val();
// We don't need an array for one selects
if ( one )
return value;
// Multi-Selects return an array
values.push( value );
}
}
return values;
// ...
},
:selected セレクターを呼び出すと、すべての選択要素の子孫をループして、設定する .selected プロパティを探し、いずれかの配列を返します。いずれにせよ、これを行うとすべての子孫がループするので、これを行わないでください。