जब आप किसी शीर्षक विशेषता वाले तत्व पर क्लिक करेंगे, तो शीर्षक टेक्स्ट वाला एक चाइल्ड एलिमेंट जोड़ दिया जाता है। आइए एक उदाहरण देखें -
एचटीएमएल के लिए -
<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();
}
}); निम्नलिखित है CSS -
.demo {
border-bottom: 2px dotted;
position: relative;
}
.demo .title {
position: absolute;
top: 15px;
background: gray;
padding: 5px;
left: 0;
white-space: nowrap;
}