zoukankan      html  css  js  c++  java
  • 简易留言板

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>无标题文档</title>
    <script>
    window.onload = function(){
        var oTxt = document.getElementById('txt');
        var oBtn = document.getElementById('btn');
        var oBox = document.getElementById('box');
        
        oBtn.onclick = function(){
            var oLi = document.createElement('li');
            oLi.innerHTML = oTxt.value + '<a href="javascript:;">隐藏</a>';
            
            if(oBox.children.length){
                oBox.insertBefore(oLi,oBox.children[0]);    
            }else{
                oBox.appendChild(oLi);        
            }
            
            oTxt.value = '';
            oLi.children[0].onclick = function(){
                oBox.removeChild(this.parentNode);
            }
        }
    }
    </script>
    </head>

    <body>
    user:<input type="text" value="" id="txt"/>
    <input type="button" value="添加" id="btn"/>
    <ul id="box"></ul>
    </body>
    </html>

  • 相关阅读:
    动态数组的实现案例
    随机验证码实现案例
    wince下的CPU和内存占用率计算
    RT-Thread--时间管理
    RT-Thread--线程管理
    RT-Thread--内核基础
    RT-Thread--简介
    Git基本操作
    STM32F103/429串口IAP+Ymodem升级
    KEIL_MDK生成Bin文件
  • 原文地址:https://www.cnblogs.com/guolimin/p/6087249.html
Copyright © 2011-2022 走看看