我有一個單選按鈕,處於禁用狀態。我只想在僅禁用該單選按鈕時將其懸停在某個文本上。代碼是如下:如何在懸停的單選按鈕上顯示文本?
的JavaScript:
$(document).ready(function(){
$('#content').on('mouseenter', 'input#Radio', showBox);
$('#content').on('mouseleave', 'input#Radio', hideBox);
function showBox(e){
var x = e.pageX + 20;
var y = e.pageY + 20;
$('#hoverbox').fadeIn();
$('#hoverbox').offset({ left: x, top: y });
}
});
function hideBox(){
$('#hoverbox').fadeOut();
}
CSS:
#hoverbox {
display:none;
position:absolute;
}
#text {
width:100px;
height:100px;
background:#000;
}
.pop-up-bc-tooltip {
float:left;
padding:14px 12px;
border:2px solid #626367;
font: normal 14px Arial, Helvetica, sans-serif;
-moz-border-radius: 2px;
border-radius: 2px;
background:#fffcfc;
}
HTML:
<div id="hoverbox" class="pop-up-bc-tooltip">
please complete the required fields above<br/>
prior to selecting your travel insurance
</div>
<div id="content">
<input type="radio" id="radiobtn"/>Hi
<div id="hoverbox" class="pop-up-bc-tooltip">
please complete the required fields above<br/>
prior to selecting your travel insurance
</div>
</div>
id元素'#Radio'在哪裏?禁用的單選按鈕在哪裏? – nkmol
ID必須是唯一的。你有2個'hoverbox'。 –