I originally wanted to use some ready-made Plug-ins. I found a few plug-ins that were complicated. I wanted to implement a small effect and it didn't need to be too complicated. So I finally planned to write one myself!
Effect: place the cursor over the text and a prompt box appears!
Effect:
Test results: Firefox, IE6/7/8
Note: No parameter customization is made, and it may be improved in the future. If you want to change the display effect, you can directly adjust the CSS style in Js! Thank you for your advice!
Code
CopyCode The Code is as follows: (function ($ ){
$. FN. jntooltips = function (){
VaR DIV = Document. createelement ("Div ");
Div.style.css text = 'width: 300px; line-Height: 25px; Border: solid 1px # f3a007; Background-color: # fbe6bd; padding: 5px 10px; font-size: 12px; position: absolute'
Div. onclick = function () {$ (DIV). Remove ();};
$ (This). Mouseover (function (e ){
If (! E) {e = Window. event ;}
Div. innerhtml = $ (this). ATTR ("title ");
$ (This). ATTR ("title ","");
VaR Doc = document.doc umentelement? Document.doc umentelement: Document. Body;
Div. style. Left = (E. clientx + Doc. scrollleft + 5) + "PX ";
Div. style. Top = (E. clienty + Doc. scrolltop + 5) + "PX ";
Document. Body. appendchild (DIV );
}). Mouseout (function (){
$ (This). ATTR ("title", Div. innerhtml );
$ (DIV). Remove ();
});
}
}) (Jquery );
Usage:Copy codeThe Code is as follows: $ (document). Ready (function (){
$ ("A"). jntooltips ();
});