ToolTipsJQEURY plug-in's concise and small prompt box effect _ jquery

Source: Internet
Author: User
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 ();
});

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.