In this post we will discuss how we can create a tool tip by using JQuery. Here we are not going to use any plugin to create tool tip. We will use only jQuery and html table for this demo. I hope you will like this.
Background
Recently, I was going through a situation to create a tool tip for my grid. As we all know there are plenty of plugins available for the tool tip generation. But I was not ready to go with any plugin for this. So I thought of creating it manually.
Using the code
Firstly, we will create a page and an html table.
Now if you run your page and you can see the table.
Now we will add our script to the page.
- <script>
- $(document).on('mouseover', '.table td', function () {
- $(this).attr('title', $(this).text());
- });
- </script>
Here what we are doing is, we are just appending the title attribute for the td element in the mouseover event. Now run your page, and see our tool tip works perfectly.
We have done it finally.
Complete Code
- <!DOCTYPE html>
- <html>
- <head>
- <title>Create Tooltip Without Any Plugins</title>
- <script src="jquery-2.0.2.min.js"></script>
- <script>
- $(document).on('mouseover', '.table td', function () {
- $(this).attr('title', $(this).text());
- });
- </script>
- </head>
- <body>
- <table class="table" border="1" style="width: 100%">
- <tr>
- <td>Sibi</td>
- <td>Ajay</td>
- <td>50</td>
- </tr>
- <tr>
- <td>Ansu</td>
- <td>Akhil</td>
- <td>94</td>
- </tr>
- <tr>
- <td>Shanto</td>
- <td>Libin</td>
- <td>80</td>
- </tr>
- </table>
- </body>
- </html>
Did I miss anything that you may think which is needed?Have you ever faced this issue in your programming life? I hope you liked this article. Please share me your valuable suggestions and feedback.
Your turn. What do you think?
A blog isn’t a blog without comments, but do try to stay on topic. If you have a questions, the please mention it in the comments section.


Sibeesh VenuTOP 100Posted Sep 26, 2015, 9:45 PM EDT
Gopi Chand thanks dude
Sibeesh VenuTOP 100Posted Sep 26, 2015, 9:45 PM EDT
Rakesh Chavda thanks Buddy
Sibeesh VenuTOP 100Posted Sep 26, 2015, 9:44 PM EDT
Santhakumar Munuswamy thank you
Gopi ChandPosted Sep 26, 2015, 10:47 AM EDT
Nice work Sibeesh :)
RakeshPosted Sep 26, 2015, 9:18 AM EDT
Good share buddy
Santhakumar MunuswamyPosted Sep 26, 2015, 8:20 AM EDT
Nice share
Sibeesh VenuTOP 100Posted Sep 26, 2015, 12:34 AM EDT
Afzaal Ahmad Zeeshan yes we can but, I had a particular scenario. I was using a third party tool, so if I want tooltip, I was forced to include a js file. So I thought of creating it cynically. I was using jqx jqwidget grid.
Afzaal Ahmad ZeeshanTOP 100Posted Sep 26, 2015, 12:32 AM EDT
But, Sibeesh this could have been done efficiently by just writing the title attribute in the element itself.
Sibeesh VenuTOP 100Posted Sep 25, 2015, 11:31 PM EDT
Ajeet Mishra Thanks buddy.
Sibeesh VenuTOP 100Posted Sep 25, 2015, 11:30 PM EDT
N Vinodh Thanks buddy.
Sibeesh VenuTOP 100Posted Sep 25, 2015, 11:30 PM EDT
Pankaj Kumar Choudhary Thanks buddy.
Sibeesh VenuTOP 100Posted Sep 25, 2015, 11:29 PM EDT
Sujeet Suman Thanks buddy.
Sibeesh VenuTOP 100Posted Sep 25, 2015, 11:29 PM EDT
Ankit Bansal Thanks buddy.
Sibeesh VenuTOP 100Posted Sep 25, 2015, 11:29 PM EDT
Harshad Pansuriya Thanks buddy.
Ajeet MishraPosted Sep 25, 2015, 10:12 PM EDT
nice
Vinodh NarayananPosted Sep 25, 2015, 9:26 PM EDT
nice share
Pankaj Kumar ChoudharyTOP 100Posted Sep 25, 2015, 8:58 PM EDT
Nice Article Sir..........
Sujeet SumanPosted Sep 25, 2015, 8:32 PM EDT
Nice Article........................
Ankit BansalPosted Sep 25, 2015, 8:30 PM EDT
Awesome buddy..thanks for sharing..
Harshad PansuriyaPosted Sep 25, 2015, 8:15 PM EDT
Nice Share