I am trying to make it so that an alert pops up when you click the image but for some reason it doesn’t work and tells me I need to put a ")" even though one is already there. Someone pls help.
<img src="descarga (3).png" height="20">
<button
onclick=(alert('yay you clicked'))
>
click me!! </button>
4
Answers
You need to add
"
around the js function in the declaration ofonclick
.Something like :
Please see : event onclick doc
You need to add the listener to the image itself and not a button.
Syntax Error – use "" instead ()
If you want to display alert on image you need to add onclick in image and also wrap alert in ""