Optimized JS to hide empty ToC.

This commit is contained in:
Cotes Chung 2019-11-25 00:19:03 +08:00
parent 75b825cdde
commit 0e6edb0d1a
2 changed files with 7 additions and 4 deletions

View file

@ -6,8 +6,11 @@
*/
$(function() {
// Hide ToC title if there is no head
if ($("#toc-wrap>nav#toc>ul>li").length == 0) {
$("#toc-wrap>h3").addClass("hidden");
if ($("#post-wrap .post-content h1").length == 0
&& $("#post-wrap .post-content h2").length == 0
&& $("#post-wrap .post-content h3").length == 0
&& $("#post-wrap .post-content h4").length == 0
&& $("#post-wrap .post-content h5").length == 0) {
$("#toc-wrap").addClass("hidden");
}
});

View file

@ -1 +1 @@
$(function(){if($("#toc-wrap>nav#toc>ul>li").length==0){$("#toc-wrap>h3").addClass("hidden")}});
$(function(){if($("#post-wrap .post-content h1").length==0&&$("#post-wrap .post-content h2").length==0&&$("#post-wrap .post-content h3").length==0&&$("#post-wrap .post-content h4").length==0&&$("#post-wrap .post-content h5").length==0){$("#toc-wrap").addClass("hidden")}});