顯示元件I具有包含7個對象,其是如下的問題的數組:如何從陣列環
var questions = [ {question: 'Which turkish club did former Leeds player Harry Kewell join in 2008, which caused an uproar amongst Leeds supporters?'},
{question: 'Who is the former Liverpool star who beat Ruud Van Nistelrooy\'s record of most prolific foreign goalscorer in their debut in the Premier League?'},
{question: 'Who scored Liverpool\'s winner in \'that\' first 4-3 game against Kevin Keegan\'s Newcastle United in April 1996?'},
{question: 'Which club was former Leeds Unted player Eric Cantona sold to in 1992?'},
{question: 'Which former Aston Villa and Ireland midfielder went on to become a regular TV pundit with ITV?'},
{question: 'How many European Cups had Liverpool won up to and including 2007-8?'},
{question: 'Name the Liverpool scorers for the \'miracle of Istanbul\'.'}
];
我想當通過單擊按鈕使用循環來顯示每個問題警報功能。我只需要顯示已經在數組中的問題。我不想問用戶什麼。所以當單擊按鈕時,我只想拉出第一個元素並使用alert()顯示,然後再次單擊該按鈕時,我想顯示第二個元素,直到通過單擊該按鈕顯示了所有元素。
例如,我曾嘗試使用該按鈕的點擊數財產與一個for循環一起,試圖讓這個問題顯示如下所示的JSFiddle:
但是這顯示所有的問題在點擊一下數組。
感謝
編程中的「不確定」可以通過嘗試和嘗試輕鬆兌換。 – Xufox 2015-03-25 12:52:28
你不需要使用循環。你有理由不得不打電話問題[我],我是這個人點擊按鈕的次數。 – Unex 2015-03-25 12:52:47