【发布时间】:2021-10-17 15:58:18
【问题描述】:
我正在尝试制作一个随机报价生成器,通过单击按钮生成报价。我认为我做的一切都是正确的,但是一旦点击了按钮,什么都没有发生。
这里是代码
HTML 代码
<div class="quote-box">
<p id = "quote-generator"> this is where the quote will go </p>
<button class="btn" onclick="function newQuote()"> Next </button>
</div>
JS 代码
var list = [
'/"Your mind will always believe what you tell it. Feed it faith. Feed it the truth. Feed it with love. /"',
'/"A problem is a chance for you to do your best./"',
'/"Learn how to be happy with what you have while you pursue all that you want./"',];`
const randomNumber = Math.floor(Math.random()*list.lenght);
function newQuote() {
document.getElementById("quotes-generator").innerHTML = list [randomNumber];`
}
【问题讨论】:
标签: javascript html jquery css arrays