zoukankan      html  css  js  c++  java
  • 测试

    cardList = [];
    cardList.AddData = function (data) {
        this[this.length] = data;
    }
    cardList.DelData = function (id) {
    //    for (var i = id; i < this.length - 1; i++) {
    //        this[i] = this[i + 1];
    //    }
        this.length--;
    }

    function getElement(id) {
        return document.getElementById(id);
    };
    function getElementByName(name) {
        return document.getElementsByName(name);
    };

    window.onload = function () {
        getElement("btnAdd").onclick = function () {
            var data = getElement("txtCard").value;
            var tmpRow = getElement("rowTmp").childNodes[0].cloneNode(true);
            tmpRow.childNodes[0].innerHTML = data; //getElement("context").childNodes.length + 1;      
            getElement("context").appendChild(tmpRow);

            cardList.AddData(data);
            getElement("txtCard").value = "";
            getElement("txtCard").focus();
        };

        getElement("btnDel").onclick = function () {
            var context = getElement("context");
            if (context.lastChild) {
                context.removeChild(context.lastChild);
                cardList.DelData();
            }
        };

        getElement("btnOK").onclick = function () {
            alert(cardList);
        };
    }

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
        <script type="text/javascript" src="js/Test.js"></script>
    </head>
    <body>
        <div>
         <input type="text" id="txtCard"  value="" />
            <button id="btnAdd">
                +</button>
            <button id="btnDel">
                -</button>
        </div>
        <div id="context">
        </div>
        <div>
            <button id="btnOK">
                OK</button>
            <button id="btnCancel">
                Cancel</button>
        </div>
        <div id="rowTmp" style="display: none">
            <div>
                <label>
                    </label>
               
            </div>
        </div>
    </body>
    </html>

  • 相关阅读:
    php 判断访问是否是手机或者pc
    SQLSTATE[HY000] [2002] No such file or directory
    No input file specified.
    Call to undefined function openssl_decrypt()
    Parse error: syntax error, unexpected 'class' (T_CLASS)
    tp5关联模型进行条件查询
    windows下php7.1安装redis扩展以及redis测试使用全过程
    SourceTree跳过初始设置
    对象数组(JSON) 根据某个共同字段 分组
    SDUT 3377 数据结构实验之查找五:平方之哈希表
  • 原文地址:https://www.cnblogs.com/movemoon/p/4740208.html
Copyright © 2011-2022 走看看