按ID,选择和属性选择选项

时间:2019-06-03 09:16:24

标签: jquery html dom select

我可以选择带有以下选项的html:

<select class="selectpicker ng-untouched ng-valid ng-not-empty ng-dirty ng-valid-parse" id="email_select" ng-model="tab.employeeForEmailContact" data-live-search="true" title="Select employee" tabindex="-98"><option class="bs-title-option" value="">
    <option ng-repeat="employee in tab.companyEmployees" value="1" type_customer="basic" tab_index="0" id="e_1" class="ng-binding ng-scope">Kokoczko Anna
    <option ng-repeat="employee in tab.companyEmployees" value="2" type_customer="basic" tab_index="0" id="e_2" class="ng-binding ng-scope">Jajko Patrycja
</select>

我想通过jquery和tab_index属性获得选择的选项。我正在尝试做类似的事情:

$("#email_select option:selected [tab_index='1']").attr('type_customer');

但是我的结果是不确定的,如图所示:

enter image description here

当我尝试仅按选定的选项查找时,它可以正常工作,但使用选项卡索引却不能:

enter image description here

我应该如何正确做?我会很感激

0 个答案:

没有答案