随机一言和古诗词代码
•分享
1729
0
每次刷新页面随机展示一句古诗词和随机一言
[reply]
<script src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8"></script>
<div id="poem_sentence"></div>
<div id="poem_info"></div>
<script type="text/javascript">
jinrishici.load(function(result) {
var sentence = document.querySelector("#poem_sentence")
var info = document.querySelector("#poem_info")
sentence.innerHTML = result.data.content
info.innerHTML = '——【' + result.data.origin.dynasty + '】' + result.data.origin.author + '《' + result.data.origin.title + '》'
});
</script>
[/reply]
随机一言代码
[reply]
<p id="hitokoto">
<a href="#" id="hitokoto_text">:D 获取中...</a>
</p>
<script>
fetch('https://v1.hitokoto.cn')
.then(response => response.json())
.then(data => {
const hitokoto = document.querySelector('#hitokoto_text')
hitokoto.href = `?uuid=${data.uuid}`
hitokoto.innerText = data.hitokoto
})
.catch(console.error)
</script>
上一篇 : 我的书架已完成
下一篇 : 一段代码禁止右键查看源代码和按键F12