【发布时间】:2015-04-21 09:36:53
【问题描述】:
我在女巫上有一个禁用按钮,我想在鼠标悬停时设置一个效果,所以我有这个代码:
$commentAddTimeshitForbiden = AddPopupJQ("Button disable");
echo "<input type='button' value='Validate' $commentAddTimeshitForbiden/>";
AddPopupJQ 只是一个函数,它允许在我的输入中添加一个类,并且在参数中给出的文本后面加上一个标题。
function AddPopupJQ($text='', $title='')
{
return "class='popupjq' data-popupjq_text='" . htmlspecialchars(stripslashes($text), ENT_QUOTES | ENT_HTML401, "ISO-8859-15") . "' data-popupjq_title='" . htmlspecialchars(stripslashes($title), ENT_QUOTES | ENT_HTML401, "ISO-8859-15") . "'";
}
在我拥有jquery function 之后,他将获取拥有className 的所有元素并在mouse pass hover 元素时打印popUp。
function popupJQ() {
$(".popupjq").each(function(index) {
//Récuperation des données/paramètres
var title = ($(this).data('popupjq_title')) ? $(this).data('popupjq_title') : '';
var text = ($(this).data('popupjq_text')) ? $(this).data('popupjq_text') : '';
//Pour l'accessibilité, on ajoute la balise Alt aux images
if ($(this).is("img")) {
var sep = (title && text) ? " : " : "";
$(this).attr("alt", title + sep + text);
}
//Création de la tooltip
var txt = "";
if (title)
txt += "<B><FONT class='tooltitle'>" + title + "</FONT></B><br>";
if (text)
txt += "<FONT class='tooltext'>" + text + "</FONT>";
if(txt){
$(this).tooltipster({
content: $(txt),
position: 'bottom-left',
delay: 100,
debug: false,
speed: 0
});
}
});
}
问题是按钮启用时它起作用,但禁用时不起作用。
我认为这是因为当按钮为disable 时事件悬停停止。我该怎么做才能让它发挥作用。
【问题讨论】:
-
请包含所有相关代码
-
@Kvasir 输入你的代码。
-
谢谢你,它的工作
-
Kvasir 没问题 :)
标签: javascript jquery html css