jQuery - Loop through and display images in an array with certain property value for specified time

后端 未结 2 1205
情话喂你
情话喂你 2021-01-29 01:59

My goal is to display a deck of cards on a webpage. There will be one button on the page per suit of cards, so four buttons for Hearts, Diamonds, Clubs, Spades, respectively. Wh

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-29 02:15

    You are checking for index in displayedCards which will always return -1 as you are pushing the object into it not the index. So the line of code

    if(!$.inArray(index, displayedCards) > -1 && deck[index].suit == "Hearts")
    

    Should be

    if(!$.inArray(c, displayedCards) > -1 && deck[index].suit == "Hearts")
    

提交回复
热议问题