I have a question about javascript.
<!DOCTYPE html>
<html lang="ja">
<head>
<title>java Script</title>
<metacharset="utf-8">
</head>
<style>
body{
display:flex;
flex-wrap:wrap;
}
.box{
width: 100px;
height —100px;
background:skyblue;
cursor —pointer;
transition —0.8s;
margin —08px8px0;
}
.circle{
background:red;
border-radius: 50%;
transform —rotate (360 deg);
}
</style>
<body>
<script>
'use strict';
const div = document.createElement('div');
div.classList.add('box');
div.addEventListener('click, function(){←I think I'm wrong here
div.classList.toggle('circle');
});
document.body.appendChild(div);
</script>
</body>
</html>
I made it while looking at the dot installation. In the dot installation, something like a blue square appears.
When I open it in my browser, nothing comes out.And when I looked it up in the developer tool, there was an error and it says SCRIPT1015:SCRIPT1015:Uninterrupted string constant
.
div.addEventListener('click, function(); {
was mentioned.
Please let me know what happened.
div.addEventListener('click, function(){
missing '
.
Correctly
div.addEventListener('click', function(){
Isn't it?
Unterminated string constant
is an error that means "I don't know where the string ends."
So you can think that '
is missing.
addition:
SCRIPT 5009: SCRIPT 5009: 'ducument' is not defined
It's a misspelling.This is the document
.
Therefore,
div.addEventListener('click', function(){
and
const div= document.createElement('div')
I think I need to fix it in two places.
© 2024 OneMinuteCode. All rights reserved.