近期看到很多站点评论框中自动加入了一言内容,秉承着好奇的心理研究了一番。
现将代码分享如下,在header、footer等位置添加以下代码:
<script> $.getJSON("https://api.yum6.cn/yan.php?format=json",function(data){ $("#comment").text(data.text); }); $(function(){ $("#comment").click(function() { $(this).select(); }) }) </script>