Uncaught TypeError: Cannot set properties of null (setting 'src') = `Cards/${dCard1}.png`;

14 views Asked by At

I'm currently developing a JavaScript Blackjack game, and everything is working fine except for one issue. When attempting to play the game again at the end, I encounter an error. Could someone please assist me with resolving this error?

The js script in html is at end of the body

1

There are 1 answers

0
akhaled01 On

Im thinking the issue is that you are trying to set the src of an element that doesn't exist in the DOM.

This issue is especially prevelant when you are removing stuff from the DOM. Try playing the game and inspect the element you are trying to retrieve in the Dev Console tools. There is a chance it gets removed at some point in the game, at which point its "null".

More details would also be helpful!