在JavaScript中使用Document.title()吗?
在title属性设置或返回的值title属性的元素,无非是提供关于元素的额外信息。这主要用作工具提示,在鼠标悬停时显示文本。Javascript提供了document.title()来获取标题。
语法
document.title();
示例
在以下示例中,在'p'标记内使用了abbr 属性, 并使用document.title()方法找到了相应的标题缩写。稍后,结果将显示在输出中。
<html>
<body>
<p><abbr id="Abbr" title="Abraham lincoln"></abbr>A-l is one of the best presidents of America </p>
<p id="title"></p>
<script>
var x = document.getElementById("Abbr").title;
document.getElementById("title").innerHTML = x;
</script>
</body>
</html>输出结果
A-l is one of the best presidents of America Abraham lincoln
热门推荐
10 开学新人祝福语简短英语
11 年前幸福祝福语大全简短
12 50多岁生日简短祝福语
13 蛋糕生日弥勒祝福语简短
14 拥有爱的祝福语简短
15 早日回国祝福语简短英语
16 跨年简短祝福语学生毕业
17 嫂子生日英语祝福语简短
18 51祝福语毕业文案简短