zoukankan      html  css  js  c++  java
  • 字节跳动笔试题

    要求:

    解答:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    input {
    180px;
    }
    ul{
    display: none;
    margin-top: 0px;
    padding: 0px;
    }
    li{
    height: 20px;
    line-height: 20px;
    list-style-type: none;
    180px;
    margin-left: 0px;
    padding-left: 5px;
    border-bottom: 1px solid #ddd;
    border-left:1px solid #ddd;
    border-right: 1px solid #ddd;

    }
    li:hover>.delete {
    display: block;
    }
    .delete {
    color: blue;
    display: none;
    margin-left: 100px;
    margin-top: -20px;
    cursor: pointer;
    }
    </style>
    </head>
    <body>
    <input type="text" />
    <ul>
    </ul>
    <script>
    let ul=document.getElementsByTagName("ul")[0];
    function venter(){
    let kvalue = document.getElementsByTagName("input")[0].value;
    let span = document.createElement("span");
    span.innerHTML = "删除";
    span.onclick = function(){
    this.parentNode.parentNode.removeChild(this.parentNode)
    };
    span.className = "delete";
    let node=document.createElement("li"); //创建一个li节点
    node.innerHTML = "<span>"+kvalue+"</span>";
    node.appendChild(span);
    ul.appendChild(node)
    document.getElementsByTagName("input")[0].value = "";
    }

    document.onkeyup=function(e){
         e=e||window.event;
         e.preventDefault();
         switch(e.keyCode){
         case 13:
                venter();
                break;
       }
    }

    document.getElementsByTagName("input")[0].onfocus = function(){
    let ul=document.getElementsByTagName("ul")[0];
    ul.style.cssText="display:block;";
    }
    </script>
    </body>
    </html>
  • 相关阅读:
    返回一个整数数组中最大子数组的和——首尾相接
    第四周学习进度
    数组--二维数组求最大子数组
    第三周个人作业--数组从文件读取返回子数组的最大值
    第三周学习进度
    第二周个人作业--数组
    开课博客
    《软件需求工程》阅读笔记03
    河北省重大技术需求征集系统(8)
    等待网站响应时间分析
  • 原文地址:https://www.cnblogs.com/lzcblog/p/10655789.html
Copyright © 2011-2022 走看看