zoukankan      html  css  js  c++  java
  • 添加删除

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script>
    window.οnlοad=function(){
    var oUl=document.getElementById('ul1');
    var oTxt1=document.getElementById('txt1');
    var oBtn=document.getElementById('btn1');
    oBtn.οnclick=function(){
    var oLi=document.createElement('li');
    oLi.innerHTML=oTxt1.value+'<a href="javascript:;">删除</a>';
    oLi.children[0].οnclick=function(){
    oUl.removeChild(oLi);

    }
    if(oUl.children.length==0){
    oUl.appendChild(oLi);
    }else{
    oUl.insertBefore(oLi,oUl.children[0]);

    }
    oTxt1.value='';
    }
    }
    </script>
    </head>
    <body>
    <input type="text" id="txt1">
    <input type="button" value="添加" id="btn1">

    <ul id="ul1">
    </ul>
    </body>
    </html>

  • 相关阅读:
    poj 2718 Smallest Difference
    AtCoder Beginner Contest 100 2018/06/16
    aoj 0009 Prime Number
    poj 1930 Dead Fraction
    poj 3669 Meteor Shower
    aoj 0121 Seven Puzzle
    poj 2429 GCD & LCM Inverse
    aoj 0005 GCD and LCM
    aoj 0558 Cheese
    aoj 0033 玉
  • 原文地址:https://www.cnblogs.com/Xuman0927/p/12050855.html
Copyright © 2011-2022 走看看