Clicking an image to change text below image using onclick

I can get my text to change using <button onclick="displayNewtext()"> but I cannot get a <img src="image.jpg" onclick="displayNewtext()"> to do it. Whats the correct code to use to make a click on an image trigger an onclick which runs a function that replaces text in the DOM?

Can you show a consolidated example showing this behavior? It sounds that a <button> has text but an <img> does not, so no text can update. Just a guess though. We need to see your code :slight_smile: .

1 Like