随机一言和古诗词代码
•分享
1973
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>
文章标题:随机一言和古诗词代码
本文链接:https://timelogs.cn/archives/453/
许可协议:CC BY-SA 4.0
上一篇 : 我的书架已完成
下一篇 : 一段代码禁止右键查看源代码和按键F12