Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Getting Tooltips for mobile browsers in HTML
When you will click on an element with a title attribute, a child element with title text is appended. Let us see an example −
For HTML −
<p> The <span class="demo" title="this is underscore">underlined</span> character. </p>
jQuery −
$("span[title]").click(function () {
var $title = $(this).find(".title");
if (!$title.length) {
$(this).append('<span class="title">' + $(this).attr("title") + '</span>');
} else {
$title.remove();
}
});
The following is the CSS −
.demo {
border-bottom: 2px dotted;
position: relative;
}
.demo .title {
position: absolute;
top: 15px;
background: gray;
padding: 5px;
left: 0;
white-space: nowrap;
}Advertisements