在函数中添加Blogger博客标题

时间:2016-09-29 15:02:28

标签: javascript jquery blogger

我设计了一些Blogger模板,我想在客户博客的标题中添加功劳。显示Blogger博客标题的标记是<data:blog.title/>,但在此函数中不起作用:

function credit(){var creditsyear = new Date(),fullYear = creditsyear.getFullYear(),html =“”+ fullYear +“©。Credit”,containers = document.getElementsByClassName(“content”),容器= document.body的; if(containers.length&gt; 0)container = containers [containers.length-1]; container.insertAdjacentHTML( “beforeend”,HTML); }; $(文件)。就绪(信用);

如何让它显示如下标题: 2016 © Blog Title. Designed by Blogger

1 个答案:

答案 0 :(得分:0)

它对我有用。也许你忘了加载jQuery

function credit(){ 
  var creditsyear = new Date(), fullYear = creditsyear.getFullYear(), html=""+fullYear+" © . Credit", containers=document.getElementsByClassName("content"), container=document.body; 

if(containers.length > 0) 
  container=containers[containers.length-1];

container.insertAdjacentHTML("beforeend",html); 
}; 
$(document).ready(credit);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<html>
  <body>
    <div class="content">
      <div>test1</div>
      <div>test2</div>
    </div>
  </body>
</html>