I didn't want to write JQ plug-ins, but it seems that JQ is not so convenient to reference. I have also written some small JS methods before, but writing JQ plug-ins is the first time I wanted to use some ready-made Plug-ins. I wanted to implement a small effect when I found several plug-ins that are complicated, it doesn't need to be too complicated, so I plan to write it 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
The Code is as follows:
(Function ($ ){
$. Fn. JNToolTips = function (){
Var p = document. createElement ("p ");
P.style.css Text = 'width: 300px; line-height: 25px; border: solid 1px # F3A007; background-color: # FBE6BD; padding: 5px 10px; font-size: 12px; position: absolute'
P. onclick = function () {$ (p). remove ();};
$ (This). mouseover (function (e ){
If (! E) {e = window. event ;}
P. innerHTML = $ (this). attr ("title ");
$ (This). attr ("title ","");
Var doc = document.doc umentElement? Document.doc umentElement: document. body;
P. style. left = (e. clientX + doc. scrollLeft + 5) + "px ";
P. style. top = (e. clientY + doc. scrollTop + 5) + "px ";
Document. body. appendChild (p );
}). Mouseout (function (){
$ (This). attr ("title", p. innerHTML );
$ (P). remove ();
});
}
}) (JQuery );
Usage:
The Code is as follows:
$ (Document). ready (function (){
$ ("A"). JNToolTips ();
});