我正在使用 Jquery UI 自动完成插件作为直接搜索词建议工具.除了我无法移动结果框外,它已启动并运行,没有任何问题.我基本上需要将它向左移动 20 像素,向下移动 4 像素.我试图覆盖 Jquery UI CSS,但无法重新定位框.
I am using the Jquery UI Autocomplete plugin for a straight forward search term suggestion tool. It is up and running with no problems except that I cannot move the results box. I basically need to move it 20 pixels to the left and 4 pixels down. I have attempted to overwrite the Jquery UI CSS, but have not been able to reposition the box.
非常感谢有此问题经验的人提供任何帮助.
Any help from someone experienced with this issue would be greatly appreciated.
这里有一种方法可以做到这一点,点击 open 事件并在该事件发生时更改菜单的位置:
Here's one way you could do it, tapping into the open event and changing the position of the menu when that event occurs:
$("#autocomplete").autocomplete({
appendTo: "#results",
open: function() {
var position = $("#results").position(),
left = position.left, top = position.top;
$("#results > ul").css({left: left + 20 + "px",
top: top + 4 + "px" });
}
});
我还使用 appendTo 选项来轻松查找包含菜单的 ul.不过,您可以在没有此选项的情况下执行此操作.
I'm also using the appendTo option to make finding the ul that contains the menu easily. You could do it without this option though.
这是一个工作示例:http://jsfiddle.net/9QmPr/
这篇关于重新定位 Jquery UI 自动完成结果框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
用于创建头像的 jQuery/JavaScript 库?jQuery/JavaScript Library for avatar creation?(用于创建头像的 jQuery/JavaScript 库?)
如何做以下掩码输入问题?How to do following mask input problem?(如何做以下掩码输入问题?)
使用 DropKick Javascript 设置值/标签的问题Issues Setting Value/Label Using DropKick Javascript(使用 DropKick Javascript 设置值/标签的问题)
如何对 jquery 插件中的私有方法进行单元测试?how to unit-test private methods in jquery plugins?(如何对 jquery 插件中的私有方法进行单元测试?)
stellar.js - 为垂直滚动网站配置偏移量/对齐元素stellar.js - configuring offsets / aligning elements for a vertical scrolling website?(stellar.js - 为垂直滚动网站配置偏移量/对齐元素?)
jQuery 屏蔽输入插件.当文本框获得焦点时选择所有jQuery masked input plugin. select all content when textbox receives focus(jQuery 屏蔽输入插件.当文本框获得焦点时选择所有内容)