Browse Source

Merge pull request #1 from xhwsd/master

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

9
style.php

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

Loading…
Cancel
Save