0
ランダムクォートジェネレータを作成しています。すでに表示されている見積もりを配列から削除する方法を理解できないので、ボタンがクリックされたときに2回表示されません。助言がありますか?ここにjavascriptがあります:見つかったアイテムをアレイリストから削除します
var quoteArray = [
{
content: "quote 1 goes in here",
author: "author 1"
},
{
content: "quote 2 goes in here",
author: "author 2"
}
];
var button = document.getElementById('quote-button'),
quote = document.getElementById('quote'),
author = document.getElementById('quote-author'),
random;
window.onload = randomQuote;
button.addEventListener('click', randomQuote);
function randomQuote(){
random = Math.floor(Math.random() * quoteArray.length);
quote.innerHTML = quoteArray[random].content;
author.innerHTML = '— ' + quoteArray[random].author;
}
ありがとうございます!
:例えば
' array.splice(I、1); ' – ahitt6345