实现的一个网页版的简易表白墙

实现的一个网页版的表白墙

实现效果

代码截图

相关代码

javascript 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="container">
        <h1>表白墙</h1>
        <P>输入相关信息,点击提交后将会展示在表格中</P>
        <div class="div1">
            <span>谁:</span><input type="text" class="edit">
        </div>
        <div class="div1">
            <span>对谁:</span><input type="text" class="edit">
        </div>
        <div class="div1">
            <span>说:</span><input type="text" class="edit">
        </div>
        <div class="div1">
            <input type="button" value="提交" class="submit" onclick="Submit()">
        </div>
    </div>
</body>
<style>
    * {
        margin: 0px;
        padding: 0px;
    }
    .container {
        width: 400px;
        margin: 0 auto;
    }
    h1 {
        text-align: center;
        margin-bottom: 20px;
        margin-top: 40px;
    }
    p {
        text-align: center;
        color: gray;
        line-height: 63px;
    }
    .div1 {
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .edit {
        margin-bottom: 20px;
        width: 200px;
        height: 30px;
    }
    span {
        width: 50px;
        margin-bottom: 20px;
    }
    .submit {
        background-color: rgb(255, 136, 0);
        color: white;
        width: 254px;
        height: 40px;
        border: none;
        border-radius: 5px;
    }
    .submit:active {
        background-color: gray;
    }

</style>
<script>
    function Submit() {
        let edits = document.querySelectorAll('.edit')
        let from  = edits[0].value
        let to  = edits[1].value
        let message = edits[2].value
        if(from == "" || to == "" || message == "") {
            return
        }
        let div = document.createElement('div')
        div.className = 'div1'
        div.innerHTML =   from + " 对 " + to + "说:" + message 
        let container = document.querySelector('.container')
        container.appendChild(div)
        for(i = 0; i < edits.length; i++) {
            edits[i].value = "";
        }
}
</script>
</html>
相关推荐
b***9101 分钟前
【SpringBoot3】Spring Boot 3.0 集成 Mybatis Plus
android·前端·后端·mybatis
G***E3167 分钟前
前端路由懒加载实现,Vue Router与React Router
前端·vue.js·react.js
Jonathan Star23 分钟前
前端需要做单元测试吗?哪些适合做?
前端·单元测试·状态模式
这儿有一堆花28 分钟前
python视觉开发
开发语言·python
eason_fan44 分钟前
解决 Monorepo 项目中 node-sass 安装失败的 Python 版本兼容性问题
前端·debug
q***73551 小时前
删除文件夹,被提示“需要来自 TrustedInstaller 的权限。。。”的解决方案
android·前端·后端
小满zs1 小时前
Next.js第八章(路由处理程序)
前端
半桶水专家1 小时前
ES Module 原理详解
前端·javascript
冴羽1 小时前
Cloudflare 崩溃梗图
前端·javascript·vue.js
Jonathan Star1 小时前
JavaScript 中,原型链的**最顶端(终极原型)只有一个——`Object.prototype`
开发语言·javascript·原型模式