qtip - 如何 - 内容:{“将一些文字添加到”attr:'id'},

时间:2012-06-11 10:18:58

标签: jquery attr qtip

我为qtip

工作了
        /* required for qtip crests to crests */
        var countyCrest =   {
                content: {
                    attr: 'id'
                },
                position: {
                    target: 'mouse',
                    adjust: {
                        mouse: true,
                        y: +10
                    }
                },
                style: {
                    classes: 'ui-tooltip-tipsy ui-tooltip-shadow',
                    tip: true
                }
        };/* end for qtip crests to crests */

我希望在每个attr:'id'之前添加“Co.”。我尝试了各种版本的

content: {
            "Co. "+attr: 'id'
},

哪个不起作用。 有人能指出我正确的方向吗? TIA

2 个答案:

答案 0 :(得分:1)

更好的是跟随:

var temp = {};

temp['Co. ' + attr] = 'id'; 
 var countyCrest =   {

     content: temp,
    ...
}

<强> DEMO


注意

您尝试的Object属性的字符串连接是不可能的。


如果你想要像@Christoph这样的回答那么你不需要连接,就像

一样写
content: {
            attr: 'Co.id'
}

答案 1 :(得分:1)

除了事实,我看不到内容属性attr选项(Documentation)(可能是另一个版本或其他),我想它应该是:

content: {
            attr: 'Co.'+'id'
},

id属性中不允许使用空格)而不是

content: {
            "Co. "+attr: 'id'
},

因为您不想更改选项的名称(固定attr),而是更改它的值。