新手问题 有人研究过 select2 吗?selecting 事件里的 e.object 获取不了父对象 select

stephen · 2014年04月18日 · 3296 次阅读

我使用 select2 来实现一个下拉功能,使用了 basic! html:

select.select_food#select_food_3
      option value="1"

javascript:

$(".select_food").select2().on("select2-selecting", function(e) {
      alert($(e.object).parent().attr("id"));
      $("#input_food_3").val(e.val);
      alert($("#input_food_3").val());
 });

他的文档说 e 有两个属性,分别为 val 和 object

val
The id of the highlighted choice object.
object
The choice object about to be selected.

但是我通过

$(e.object).parent().attr("id")

获得为空, 正确应该怎样获取

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请 注册新账号