1

The error is this one;

app.js:33 Uncaught TypeError: Cannot set property 'src' of null at HTMLButtonElement.

This is the code(javascript):

const playerHand = document.querySelector('player-hand')
playerHand.src = `assets/${this.textContent}.png`;

this is the html

<img class="player-hand" src="assets/rock.png" alt=""> 
Gabriele Petrioli
  • 191,379
  • 34
  • 261
  • 317

2 Answers2

4

You need to change

const playerHand = document.querySelector('player-hand') 

By

const playerHand = document.querySelector('.player-hand') 

Or put this is in the IMG element

scuencag
  • 664
  • 4
  • 11
1

You need to concatenate the path to the image like this.

playerHand.src = './assets/'+this.textContent+'.png';