console
const showRandomPost = () => {
const post = _.sample(data)
$('.title').html(`《${post.title}》`)
$('.epoch').html(post.epoch)
$('.author').html(post.author)
const content = post.content
.replace(/(,|。|?|;)/mg, '<br/>')
.replace("\"", '')
$('.content').html(content)
}
showRandomPost()
$('button').on('click', showRandomPost)
<img src="https://www.cutercounter.com/hits.php?id=gcoodo&nd=1&style=1" border="0" alt="visitor counter">
<div class="result">
<h1 class="title"></h1>
<div class='meta'>
<span class="epoch"></span>
<span class="author"></span>
</div>
<div class="content">
</div>
<button>换一首</button>
</div>
body {
color: #333333;
font-size: 20px;
}
.result {
text-align: center;
}
.title {
font-size: 1.5em;
margin-bottom: 10px;
}
.meta {
font-size: 0.9em;
margin-bottom: 20px;
font-weight: bold;
color: #555555;
}
.content {
margin-bottom: 20px;
}
button {
padding: 8px 15px;
font-size: 0.8em;
}