The example in this article describes the jquery method of displaying a prompt box when the mouse slides over it. Share it with everyone for your reference. The details are as follows:
1. Example of jquery prompt box displayed when the mouse slides over
1. Rendering
2. Implementation code (you need to add jquery.js, button images, and prompt box images by yourself)
HTML code
2. Example 2 of jquery prompt box displayed when the mouse slides over
When the mouse moves over the user name, a div will be displayed in the lower right corner of the mouse to display the user information
1. Rendering
2. Implementation method
There are only three big parts. One is the positioning of the div, which is the main difficulty of the effect; the second is asynchronous loading of data through ajax; the third is to use the two js attributes onmouseover and onmouseout, that is, when the mouse passes and mouse away.
3. Implementation steps
(1) First, design the style of the div to display user information. What should be noted here is that this method is not to bind a div next to each user name. It will be displayed when the mouse passes over it and hidden when the mouse leaves. There is only one div in the web page that displays information. It is positioned wherever it needs to be displayed. To do this, you need to set the positioning method of the div to absolute positioning.
HTML code:
(2)、相应css代码
(3)、定位,为了能够精确的定位并且能够方便的调用,所以先在页面中放了两个标签,分别用于保存当前鼠标的坐标
然后用js获取当前坐标并保存到标签中:
(4)、鼠标经过和离开事件js代码
$("#lblusername").html("")
$("#lblrealname").html("");
$("#sex").html("");
$("#lbladdress").html("")
$("#lblemall").html("");
}
(5)、调用
希望本文所述对大家的jQuery程序设计有所帮助。