我正在写网站,并使用qtip:
我希望当专注于字段(一个 html 元素)时,我会在每个焦点上看到一个工具提示,而当失去焦点时 - 工具提示会消失。
有两种 html 元素。输入(当有焦点时)。收音机(当没有焦点时,只需将鼠标悬停应显示工具提示)。
这是我的代码(javascript方面,我有问题,因为工具提示有时不会消失 - 为什么?)
function showtooltip(item, val, acorner, ahide) {
'use strict';
var tipCorner;
if (ahide === undefined) {
ahide = 'blur';
}
if (acorner === undefined) {
acorner = 'bottomLeft';
}
if (acorner === "topRight") {
tipCorner = "leftMiddle";
} else {
tipCorner = "topLeft";
}
setTimeout(function() {
$(item).qtip({
content: {
text: val
},
show: {
ready: true
},
hide: {
when: ahide,
delay: 0
},
style: {
//classes: 'ui-tooltip-jtools',
background: '#A2D959',
width: 400,
color: 'black',
border: {
width: 1,
radius: 3,
color: '#6699CC'
},
tip: { // Now an object instead of a string
corner: tipCorner, // We declare our corner within the object using the corner sub-option
color: '#6699CC',
size: {
x: 20, // Be careful that the x and y values refer to coordinates on screen, not height or width.
y : 8 // Depending on which corner your tooltip is at, x and y could mean either height or width!
}
}
},
position: {
corner: {
target: acorner
}
},
api: {
onHide: function() {
$(item).qtip('api').destroy();
},
onShow: function() {
setTimeout(function() { $(item).qtip('hide'); }, 2000);
}
}
});
}, 0);
}
function showtooltiph(item, val) {
'use strict';
showtooltip(item, val, 'bottomLeft', 'mouseout unfocus');
}
在 html 方面:...
工具提示有时不会隐藏,我看到几个工具提示,这是非常烦人的行为 - 可能是什么原因?
谢谢 :)