单击区域下的弹出列表


嗨,我

有一些简单的弹出列表,一旦我单击下拉菜单选项就会显示。不幸的是,该弹出窗口在CSS绝对下,没有它,弹出窗口就会在页面下方。
此外,它显示在不同浏览器中的不同位置。

 $self.next().bind('click', viewList);
    if (!settings.appendTo) {
      $self.after(createDropdown($self, selectboxCounter));
    } else {
      var offset = $self.parent().offset();
      $(settings.appendTo).append(createDropdown($self, selectboxCounter).css({
        'top': offset.top,
        'left': offset.left,
        'width': 100//'width': $self.parent().width() * 0.8
      }));
    }
  }
  $self.trigger('change');
  selectboxCounter++;
});
// Hide dropdown when click is outside of the input or dropdown
$(document).bind('click', hideDropdown);
$('.sb-custom').find('.sb-select').live('keydown', selectKeypress);
$('.sb-custom').bind('blur', clearKeyStrokes);
$(document).delegate('.sb-dropdown', 'focus', viewList);
return this;
};

我想将弹出窗口放置在父选择或菜单位置的位置。并适应不同的浏览器。

最近在

我帮助开发的小部件中遇到了这个问题。我们想出的解决方案是将弹出列表绑定到文档正文。以身体为父级,我们不必担心其他元素会隐藏弹出窗口。然后我们只是根据它从哪里弹出来绝对定位它。

var offset = $("#popupFromHere").offset();
$("#popup")
    .appendTo("body")
    .css({
        left: offset.left
        top: offset.top + $this.outerHeight(true)
    });

最新更新