Javascript 工具提示jquery中的内容文本
我试图通过jquery显示文本Javascript 工具提示jquery中的内容文本,javascript,jquery,html,Javascript,Jquery,Html,我试图通过jquery显示文本 $(function () { $(".outer").tooltip({ content: "Awesome title!", position: { my: "left+15 center", at: "right center" }, content: function () { return $(this).prop('title'); } }); }); html 您的年龄:
$(function () {
$(".outer").tooltip({
content: "Awesome title!",
position: { my: "left+15 center", at: "right center" },
content: function () {
return $(this).prop('title');
}
});
});
html
您的年龄:
当鼠标悬停在jquery中时,如何显示“Awesome title!”您需要为输入的标题指定“Awesome title!”
。
这里是最新的小提琴手:我已经更新了你的小提琴手:
只需将title属性设置为不需要的
内容
:
您将覆盖内容两次:
第一次:
content: "Awesome title!",
第二次:
content: function () {
return $(this).prop('title');
}
只需使用第二次并将title属性设置为fiddle链接。或者,您可以按照自己的意愿使用第一次而不使用title属性。。。。但是只有一个,而不是两个。因为您使用的是
.outer
的属性标题
,所以需要将title=“Awesome title!”
指定为div
具有.outer
。因此,更新的HTML变成:
<p class="outer" title="Awesome title!">
<label for="age">Your age:</label>
<input id="age"
/>
</p>
您的年龄:
看小提琴:“你有两个内容。只需删除第二个:是,但使用第二个内容:
content: function () {
return $(this).prop('title');
}
<p class="outer" title="Awesome title!">
<label for="age">Your age:</label>
<input id="age"
/>
</p>