[英]Enable effect when button disable
我在女巫上有一個禁用按鈕,我想在鼠標經過時將效果懸停在它上面,因此我有以下代碼:
$commentAddTimeshitForbiden = AddPopupJQ("Button disable");
echo "<input type='button' value='Validate' $commentAddTimeshitForbiden/>";
AddPopupJQ
只是一個函數,允許向我的輸入添加一個類,並在文本AddPopupJQ
in參數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
之后,該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
時,事件懸停已停止。 我該怎么做才能使其正常工作。
您可以按以下方式更新代碼以使用CSS實現該代碼:
<html>
<head>
<style>
input:hover:disabled {
background-color: red;
}
</style>
</head>
<body>
<input type="button" value="Disabled" disabled/>
<input type="button" value="Enabled"/>
</body>
您可以嘗試以下代碼。
$('.className').on('mouseenter',function(e){
callMyFunction();
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.