Jquery controls the absolute position of css. For example, you can move the cursor to the icon display layer to display relevant information.
Source: Internet
Author: User
[Javascript] $ (get the element obj that needs to pop up the floating box ). hover (function () {// when you move the mouse, // obtain the element objdivobjdocument that needs to pop up the floating box. getElementById (obj); // get the position of obj, left and top, IE and FF3.0... [javascript]
$ (Get the element obj that needs to pop up the floating box). hover (function (){
// When the mouse moves
// Obtain the element obj in the floating box to be displayed.
Divobj = document. getElementById (obj );
// Obtain the obj position. left, top, IE, and FF3.0 are supported.
Divobjleft = divobj. getBoundingClientRect (). left;
Divobjtop = divobj. getBoundingClientRect (). top;
// Assign values to left and top of the pop-up div
Divobjx = divobjleft + 0/* the distance between the displayed div and the left side of obj. The actual value */;
Divobjy = divobjtop + 50/* the distance between the displayed div and the top part of the obj, and the actual value */;
// Define the pop-up div
Var x = "here is the content, which can also be passed through Parameters ";
// Write data to html through insertAdjacentHTML (this parameter is not supported by Firefox, but it may be compatible with the insertAdjacentHTML attribute through code. If the compatibility code is not long, dozens of lines are supported)
Document. body. insertAdjacentHTML ("afterBegin", x );
}, Function (){
// When the mouse is removed, the div is removed through closeDiv ().
CloseDiv ("description ");
})
/* Method for removing elements in Sart */
Function closeDiv (obj ){
Var divobj = document. getElementById (obj );
Divobj. parentNode. removeChild (divobj );
}
/* End method for removing elements */
/* Start compatible code makes Firefox compatible with insertAdjacentHTML attributes */
If (typeof HTMLElement! = "Undefined "&&! HTMLElement. prototype. insertAdjacentElement ){
HTMLElement. prototype. insertAdjacentElement = function (where, parsedNode ){
Switch (where ){
Case "beforeBegin ":
This. parentNode. insertBefore (parsedNode, this );
Break;
Case "afterBegin ":
This. insertBefore (parsedNode, this. firstChild );
Break;
Case "beforeEnd ":
This. appendChild (parsedNode );
Break;
Case "afterEnd ":
If (this. nextSibling ){
This. parentNode. insertBefore (parsedNode, this. nextSibling );
} Else {
This. parentNode. appendChild (parsedNode );
}
Break;
}
};
HTMLElement. prototype. insertAdjacentHTML = function (where, htmlStr ){
Var r = this. ownerDocument. createRange ();
R. setStartBefore (this );
Var parsedHTML = r. createContextualFragment (htmlStr );
This. insertAdjacentElement (where, parsedHTML );
};
HTMLElement. prototype. insertAdjacentText = function (where, txtStr ){
Var parsedText = document. createTextNode (txtStr );
This. insertAdjacentElement (where, parsedText );
};
}
/* End compatible code makes Firefox compatible with insertAdjacentHTML attributes */
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service