【发布时间】:2020-04-22 19:13:37
【问题描述】:
我正在制作一个待办事项列表网站,它将表单框中输入的内容移动到右侧的 div 中。
这是网站的图片: To do list site
我试图让它发挥作用,当您在表单框中输入“洁净室”时,它会在右侧的 div 中显示为文本。
我确定我需要使用 java 脚本,有人能指出正确的方向吗?
我的 HTML 和 CSS:
* {
margin: 0;
background-color: rgb(27, 27, 27);
font-family: 'Indie Flower', cursive;
}
h1 {
font-size: 5.5vw;
color: rgb(241, 240, 240);
display: flex;
justify-content: center;
margin-top: 50px;
letter-spacing: 1px;
}
.main {
margin-left: 100px;
margin-right: 100px;
margin-top: 50px;
display: flex;
flex-direction: row;
justify-content: space-evenly;
font-size: 1vw;
color: rgb(241, 240, 240);
letter-spacing: 2px;
}
.left {
display: flex;
flex-direction: column;
}
.left h2 {
padding-bottom: 50px;
}
.left form {
border: 4px solid rgb(102, 181, 255);
border-radius: 5px;
}
.left form input {
height: 30px;
width: 100%;
color: rgb(241, 240, 240);
font-size: 24px;
letter-spacing: 1px;
border: none;
}
.box {
border: 5px solid black;
border-radius: 7px;
background-color: rgb(255, 234, 176);
width: 600px;
height: 68vh;
}
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="style.css">
<link rel="text/javascript" href="javascript.js">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://fonts.googleapis.com/css?family=Indie+Flower&display=swap" rel="stylesheet">
<title>My to do list</title>
</head>
<body>
<header>
<h1>To do list</h1>
</header>
<section class="main">
<div class="left">
<h2>Please Enter your things to do here..</h2>
<form action="">
<input type="text">
</form>
</div>
<div class="box">
</div>
</section>
</body>
</html>
非常感谢。
【问题讨论】:
-
input.addEventListener('change', () => div.innerText = input.value)
标签: javascript html css forms function