扩展 qtip 或其他选择器插件的属性



我正在尝试为 qtip 的多个实例设置一堆默认属性,但它不起作用。 是可能还是我做错了什么?

通用属性

    var qtipDefaults = {
        show: 'mouseover',
        hide: 'mouseout',
        position: {
            corner: {
                target: 'bottomLeft',
                tooltip: 'topLeft'
            }
        },
        style: {
            name: 'dark'
        }
    };

实例化 # 1

    $('#sbt_name').qtip({
        content: 'This is the Name of the Course'
    }).extend(qtipDefaults);

实例化 # 2

    var sbt_name = $('#sbt_name').qtip({
        content: 'This is the Name of the Course'
    });
    $.extend(sbt_name, qtipDefaults);

在调用 qtip 插件之前,您必须准备 qtip 参数。试试这个:

$('#sbt_name').qtip($.extend(true, {}, qtipDefaults, {
    content: 'This is the Name of the Course'
}));

$.extend()合并两个或多个对象。 true参数表示它将进行深度复制。第一个对象为空,用于保持原始 qtipDefaults 不变。

最新更新