April 9, 2012
html mouse over event, can't show dialog
Question by user595234
I want to show a tooltip based on mouse over event . I have tried this code, but failed, nothing will show up.
Please advise.
<img onmouseover="showLongText();" BORDER=0 height=15 width=15 src="images/pick-button.gif"/>
<div id="longTextDiv" style="display:none;">
ddd
</div>
<script type="text/javascript">
function showLongText(className, fldName, objId){
var longTextDiv = $("#longTextDiv");
//alert(longTextDiv);
longTextDiv.style.leftPos += 10;
longTextDiv.style.posLeft = event.clientX;
longTextDiv.style.posTop = event.clientY;
longTextDiv.style.display = "";
longTextDiv.setCapture();
}
</script>
Answer by Starx
Since you are already using jQuery. You should use
$("img").hover(function(e) {
var longTextDiv = $("#longTextDiv");
//alert(longTextDiv);
longTextDiv.css({
left : e.pageX,
top : e.pageY,
display : "block"
});
longTextDiv.setCapture();
});