jquery-ui - jquery UI 工具提示 - 'my' 和 'at' 是什么意思?为什么调用 tooltip() 两次?

标签 jquery-ui jquery-ui-tooltip

在 position 属性中,有两个选项:“my”和“at”。 我不明白如何通过这些选项配置弹出气泡的位置。 他们的意思是什么?

为了弄清楚这些选项,网上找了个例子,还是搞不明白。 比如输入框左边显示的是气泡,但是“my”的值为'right center',这是为什么呢?

为什么调用 tooltip() 两次?一个带有争论的工具提示在 on() 中被调用,而另一个没有争论的工具提示在 on() 触发器之外? 这是为什么?

示例如下:http://jsfiddle.net/tj_vantoll/kyBwU/

$('input[type="radio"]').on('change', function() {
    var className = $(this).val();
    var position;
    switch (className) {
        case 'top':
            position = { my: 'center bottom', at: 'center top-10' };
            break;
        case 'bottom':
            position = { my: 'center top', at: 'center bottom+10' };
            break;
        case 'left':
            position = { my: 'right center', at: 'left-10 center' };
            break;
        case 'right':
            position = { my: 'left center', at: 'right+10 center' };
            break;
    }
    position.collision = 'none';

    $('input[type="text"]').tooltip('option', 'position', position);
    $('input[type="text"]').tooltip('option', 'tooltipClass', className);
});

$('#options').buttonset();
$('input[type="text"]').tooltip();
$('input[value="right"]').trigger('change');

而且我尝试创建自己的,不知何故,最后一个输入文本字段总是被预选。 这是我的代码:http://jsfiddle.net/matildayipan/sks358zo/18/

最佳答案

这就是我们所拥有的documentation为。

The jQuery UI .position() method allows you to position an element relative to the window, document, another element, or the cursor/mouse, without worrying about offset parents.

我的(默认:“中心”)类型:字符串

Defines which position on the element being positioned to align with the target element: "horizontal vertical" alignment. A single value such as "right" will be normalized to "right center", "top" will be normalized to "center top" (following CSS convention). Acceptable horizontal values: "left", "center", "right". Acceptable vertical values: "top", "center", "bottom". Example: "left top" or "center center". Each dimension can also contain offsets, in pixels or percent, e.g., "right+10 top-25%". Percentage offsets are relative to the element being positioned.

在(默认:“中心”)类型:字符串

Defines which position on the target element to align the positioned element against: "horizontal vertical" alignment. See the my option for full details on possible values. Percentage offsets are relative to the target element.

关于jquery-ui - jquery UI 工具提示 - 'my' 和 'at' 是什么意思?为什么调用 tooltip() 两次?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25716819/

相关文章:

jquery-ui - 如何使用轨道:true?使工具提示仅水平跟踪鼠标

jquery-ui - jQuery UI 工具提示小部件的最大宽度

jquery - 如何禁用 jQuery UI 对话框上的按钮?

javascript - JQuery 函数中的 For 循环

jquery-ui-tooltip - 如何实时更新 Jquery UI 工具提示中的内容?

jquery - 如何在 jQuery 中输出 JSON 列

javascript - 工具提示(qTip)未关闭,jQuery

jquery - JqueryUI 和 Firefox 的奇怪问题,内容的位置不在对话框中

html - jQuery UI 对话框在 FF5 中有不需要的垂直滚动条

jquery - 无法提供固定位置以在下拉列表中添加新选项