"Html+css+javascript" Implementation to-DOS (pure DOM implementation)

Source: Internet
Author: User

Requirements: Implementing to-dos

<!     DOCTYPE html>#todoList {List-Style:none;            margin:10px 0px; padding:0;        width:600px; } #todoList li {margin-bottom:5px;            padding:10px;            border:1px solid #ccc;            Background: #f5f5f5;        position:relative;            } input {padding:10px; Font-size:16px;        border:1px solid #ccc;            } button {padding:10px 20px;            border:1px solid #ccc;            Background: #f5f5f5;            Outline:none;        Cursor:pointer;            } #todoList span {position:absolute;            right:10px;        Cursor:pointer; }    </style>varinput = Document.queryselector (' #content '); varBTN = Document.queryselector (' #btn '); vartodolist= document.queryselector (' #todoList '); varspans = Document.queryselectorall (' #todoList span '); Btn.onclick=function(){            //gets the built-in of input            varText =Input.value; //Create an LI element and add parcel content to the LI element            varLi = document.createelement (' li '); Li.innertext=text; varspan = document.createelement (' span '); Span.innerhtml= ' &times; ';            Li.appendchild (span); //Add the Li element to the ULTodolist.appendchild (LI); }            /*Spans.foreach (function (span) {Span.onclick = function () {Todolist.removechild (This.parentnod e)}})*/        //Delegating Mode BindingTodolist.onclick =function(event) {if(Event.target.nodeName = = = ' SPAN ') {                 This. RemoveChild (Event.target.parentNode); }        }    </script></body>

"Html+css+javascript" Implementation to-DOS (pure DOM implementation)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.