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>

  • 相关阅读:
    大数据内存模型(二级指针)
    多线程函数指针
    返回函数指针的函数
    动态分配二维数组指针
    俄罗斯方块学习笔记
    tailf
    tail
    cut
    split
    paste
  • 原文地址:https://www.cnblogs.com/guolimin/p/6087249.html
Copyright © 2011-2022 走看看