<select>
<option value="test">label </option>
</select>
값은에서 검색 할 수 있습니다 $select.val()
.
어때 label
?
IE6에서 작동하는 솔루션이 있습니까?
답변
이 시도:
$('select option:selected').text();
답변
안녕하세요 먼저 선택에 ID를 제공하십시오.
<select id=theid>
<option value="test">label </option>
</select>
그런 다음 선택한 레이블을 다음과 같이 호출 할 수 있습니다.
jQuery('#theid option:selected').text()
답변
참조 label
를 위해 옵션 태그에 보조 속성 이 있습니다 .
//returns "GET THIS" when option is selected
$('#selecter :selected').attr('label');
HTML
<select id="selecter">
<option value="test" label="GET THIS">
Option (also called label)</option>
</select>
답변
드롭 다운에서 특정 옵션의 레이블을 얻으려면 다음을 입력 할 수 있습니다.
$('.class_of_dropdown > option[value='value_to_be_searched']').html();
또는
$('#id_of_dropdown > option[value='value_to_be_Searched']').html();
답변
도움이되었습니다
$('select[name=users] option:selected').text()
this
키워드를 사용하여 선택기에 액세스 할 때 .
$(this).find('option:selected').text()
답변
$("select#selectbox option:eq(0)").text()
“option : eq (0)”의 0 인덱스는 검색하려는 인덱스 옵션으로 교환 할 수 있습니다.
이것은 도움이됩니다 :
http://www.myphpetc.com/2009/03/jquery-select-element-cheat-sheet.html
답변
이 시도:
$('select option:selected').prop('label');
그러면 두 스타일의 <option>
요소에 대해 표시된 텍스트가 표시됩니다 .
<option label="foo"><option>
->"foo"
<option>bar<option>
->"bar"
label
요소 내부에 속성과 텍스트 가 모두있는 경우label
경우 브라우저와 동일한 동작 인 속성을 합니다.
후손을 위해 이것은 jQuery 3.1.1에서 테스트되었습니다.
