【发布时间】:2019-10-21 11:19:47
【问题描述】:
我在这里找到了类似的解决方案: Get custom data-attribute in select2 with <select>
我已经为每个选项放置了自定义数据属性。
<option value="pen" data-price="2.5">Pen</option>
当我应用该问题的公认解决方案时,
var price = $(this).select2().find(':selected').data('price');
我得到“无法读取 null 的属性‘当前’”。
【问题讨论】:
标签: jquery jquery-select2 jquery-select2-4