zoukankan      html  css  js  c++  java
  • 空间说说的发表与删除:简易的

    <DOCTYPE html>

    <thml lang = "en">

    <head>

    <meta charset = "UTF-8">

    <title>空间</title>

    <style type = "text/css">

    *{

    padding : 0;

    margin : 0;

    }

    ul{

    list-style:none;

    }

    .box{

    width : 800px;

    height : auto;

    border : 1px solid #ccc;

    margin :100px auto;

    text-align : center;

    padding : 30px 0;

    }

    .box textarea{

    width : 450px;

    resize : none;//设置文本不能拖动

    }

    .box li{

    width : 450px;

    line-height : 30px;

    birder-bottom : 1px dashed #ccc;

    margin-left : 80px;

    text-align :left;

    }

    .box li a {

    float : right;

    }

    </style>

    <script type = "text/javascript">

    window.onload = function (){

    var btn = document.getElementsByTagName("button")[0];

    var txt = document.getElementsByTagName(textarea")[0];

    var ul = docyment.createElement("ul");

    btn.onclick = function (){

    //需要判断文本框中是否有内容

    if(txt.value == ""){

    alert("内容不能为空!!");

    return false;//让操作在这个地方终止

    }

    var newli = document.createElement("li");

    newli.linerHTML = txt.value + "<a href = 'javascript:;'>

      删除</a>";

    ul.appendChild(newli);

    //清空输入框

    txt.value = "";

    var aa = document.getElementsByTagName("a");

    //获取所有的a标签

    for(var i = 0;i< aa.length; i ++){

    aa[i].onclick = function(){

    this.parentNode.remove();

    }

    }

    }

    }

    </script>

    <body>

    <div class = "box">

    说说:<textarea name = "" id = "" cols = "30" rows = "10"></textarea>

    <button>发表</button>

    </div>

    </body>

    </html>

  • 相关阅读:
    有什么样的博客手机客户端
    v2ex thread record
    Screengrab! firefox截图插件
    现在看一次咳嗽感冒就差不多要1k了,恐怖
    海归人才网
    LinkedIn公司实现的实时搜索引擎Zoie
    xipian的php中文分词
    海归人才网
    idea
    snagit number stampsgood for ppt
  • 原文地址:https://www.cnblogs.com/liluyu123/p/6003921.html
Copyright © 2011-2022 走看看