我有一个这样的选项结构:
<select id="select-filter-item" data-hasqtip="true" title="" aria-describedby="qtip-3">
<optgroup label="Operatori" type="providers-group">
<option value="89" type="provider" google-sync="false">Johnny</option>
<option value="91" type="provider" google-sync="false">Anthony</option>
</optgroup><optgroup label="Servizi" type="services-group">
<option value="13" type="service">Hair</option>
</optgroup>我只想在Operatori optgroup中得到这个值:89-91,所以我尝试了这个解决方案:
$("#select-filter-item>option").map(function() { return $(this).val(); }).get();但不返回任何价值,为什么?
发布于 2015-10-19 15:03:52
目标选项元素的选择器错误。你需要使用:
$("#select-filter-item [type='providers-group'] option").map(function() {
return $(this).val();
}).get();工作演示
https://stackoverflow.com/questions/33217735
复制相似问题