Merge pull request #1 from xhwsd/master

优化获取网页标题
master
Mr.zou 6 years ago committed by GitHub
commit b58f9994e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -32,11 +32,10 @@
<script>hljs.initHighlightingOnLoad();</script>
<script>
$(document).ready(function(){
//获取第一个H1作为标题
var h1 = $("h1").text();
//如果获取到了H1
if(h1) {
$("title").text(h1 + " - MDtoHTML");
// 设置网页标题为第一个H标签的内容
var hText = $(":header:first").text(); // 取第一个标题Hx元素
if(hText.length > 0) {
$('title').text(hText); // 设置文档标题
}
});
</script>

Loading…
Cancel
Save