zoukankan      html  css  js  c++  java
  • 评论框

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
    .comments {
    text-align: right;
    }
    .container {
    250px;
    }
    textarea {
    resize: none;
    overflow: hidden;
    250px;
    height: 100px;
    }
    .second {
    display: none;
    }
    </style>
    </head>
    <body>
    <div class="container">
    <p>范冰冰:李晨好帅~O(∩_∩)O~</p>
    <p class="comments"><button id="commentsBtn">评论</button></p>
    </div>
    <div id="commentsPanel" class="container second">
    <div><textarea id="inputInfo"></textarea></div>
    <div class="comments"><button id="submit">提交</button></div>
    <ul id="commentsItem"></ul>
    </div>
    <script>
    var open = false;
    var commentsBtnEle = document.getElementById("commentsBtn");
    commentsBtnEle.onclick = function() {
    var commentsPanelEle = document.getElementById("commentsPanel");
    if (open) {
    commentsPanelEle.style.display = "none";
    open = false;
    } else {
    commentsPanelEle.style.display = "block";
    open = true;
    }
    }
    var submitEle = document.getElementById("submit");
    submitEle.onclick = function() {
    var inputInfoEle = document.getElementById("inputInfo");
    var val = inputInfoEle.value;
    var commentsItemEle = document.getElementById("commentsItem");
    var liEle = document.createElement("li");
    liEle.innerHTML = "妙语连珠:" + val;
    if (commentsItemEle.childNodes.length === 0) {
    commentsItemEle.appendChild(liEle);
    } else {
    commentsItemEle.insertBefore(liEle, commentsItemEle.childNodes[0]);
    }
    }
    </script>
    </body>
    </html>

  • 相关阅读:
    我所理解的readonly和const
    代码中的良好习惯从点滴做起
    常用正则表达式收集
    优化网站加载速度的14个技巧
    关于easyUI的模态对话框
    关于jq ajax封装以及ajax上传Webapi
    Linux完全卸载Oracle的操作步骤
    Linux下安装oracle的一般步骤
    CentOS Linux上安装Oracle11g笔记
    Oracle中建库时报Exception in thread main
  • 原文地址:https://www.cnblogs.com/gujinshu-wangdan/p/5574082.html
Copyright © 2011-2022 走看看