Why Am I Getting The JS Error In Line One Of My Script Syntax Error: Invalid Or Unexpected Token?
I'm trying to make the picture on the index.html page change when you push the button. Here's my HTML:
Solution 1:
var lolcatButton = document.getElementById("lolcatButton");
Change the ” to ". And the other lines.
Solution 2:
You can reorganize your code like this:
<button id="lolcatButton" onclick="showMeTheLolcat()">Show me the LOLCat!</button>
<br><br>
<img id="lolcatImage" src=https://s3.amazonaws.com/media.skillcrush.com/skillcrush/wp-content/uploads/2016/09/cat5.jpg>
<script>
function showMeTheLolcat() {
var image = "https://s3.amazonaws.com/media.skillcrush.com/skillcrush/wp-content/uploads/2016/09/cat4.jpg";
lolcatImage.src = image;
}
</script>
Post a Comment for "Why Am I Getting The JS Error In Line One Of My Script Syntax Error: Invalid Or Unexpected Token?"