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 VenuPosted Sep 27, 2015, 1:45 AM
Gopi Chand thanks dude
Sibeesh VenuPosted Sep 27, 2015, 1:45 AM
Rakesh Chavda thanks Buddy
Sibeesh VenuPosted Sep 27, 2015, 1:44 AM
Santhakumar Munuswamy thank you
Gopi ChandPosted Sep 26, 2015, 2:47 PM
Nice work Sibeesh :)
RakeshPosted Sep 26, 2015, 1:18 PM
Good share buddy
Santhakumar MunuswamyPosted Sep 26, 2015, 12:20 PM
Nice share
Sibeesh VenuPosted Sep 26, 2015, 4:34 AM
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 ZeeshanPosted Sep 26, 2015, 4:32 AM
But, Sibeesh this could have been done efficiently by just writing the title attribute in the element itself.
Sibeesh VenuPosted Sep 26, 2015, 3:31 AM
Ajeet Mishra Thanks buddy.
Sibeesh VenuPosted Sep 26, 2015, 3:30 AM
N Vinodh Thanks buddy.
Sibeesh VenuPosted Sep 26, 2015, 3:30 AM
Pankaj Kumar Choudhary Thanks buddy.
Sibeesh VenuPosted Sep 26, 2015, 3:29 AM
Sujeet Suman Thanks buddy.
Sibeesh VenuPosted Sep 26, 2015, 3:29 AM
Ankit Bansal Thanks buddy.
Sibeesh VenuPosted Sep 26, 2015, 3:29 AM
Harshad Pansuriya Thanks buddy.
Ajeet MishraPosted Sep 26, 2015, 2:12 AM
nice
Vinodh NarayananPosted Sep 26, 2015, 1:26 AM
nice share
Pankaj Kumar ChoudharyPosted Sep 26, 2015, 12:58 AM
Nice Article Sir..........
Sujeet SumanPosted Sep 26, 2015, 12:32 AM
Nice Article........................
Ankit BansalPosted Sep 26, 2015, 12:30 AM
Awesome buddy..thanks for sharing..
Harshad PansuriyaPosted Sep 26, 2015, 12:15 AM
Nice Share