CSS

Custom Mouse Hover Effect With Javascript

CSS

Realistic Image Reflection With Pure CSS

CSS

3D Flipping Loader

CSS

Netflix Logo Design With CSS

Home JavascriptSimple To Do List Javscript | Javascript Project
Javascript

Simple To Do List Javscript | Javascript Project

Facebook
Twitter
Pinterest
WhatsApp

Hey everyone. Welcome to today’s tutorial. In today’s tutorial, we will learn how to create a simple to do list app. To build this app we need HTML, CSS and Javascript.

This is an intermediate-level javascript project. If you are looking for more such tutorials to improve your javascript you can check out this playlist here. This playlist consists of more than 100 javascript projects that will help you learn javascript.

The difficulty level of these projects varies from easy to quite complex ones. Hence this playlist is suitable for all kinds of javascript learners that included javascript beginners to javascript experts.

Video Tutorial:

If you would prefer to learn by watching a video tutorial rather than reading this blog post you can check out the video down below. If you like this video consider subscribing to my youtube channel. I post new tutorials, tips and tricks related to web development every alternate day on my youtube channel.聽

Project Folder Structure:

Before we move on to coding let us take a look at what the project structure looks like. We create a project folder called – ‘To Do List’. Within this folder, we have three files. These files are – index.html, style.css and script.js. The first file is the HTML document, the next one is the stylesheet and the final file is the script file.

HTML:

We start with the HTML code. First, copy the code below and paste it into your HTML document.

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Simple To Do List</title>
    <!--Google Font-->
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500&display=swap" rel="stylesheet">
    <!--Font Awesome CDN-->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css">
    <!--Stylesheet-->
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="container">
        <div id="newtask">
            <input type="text" placeholder="Task to be done..">
            <button id="push">Add</button>
        </div>
        <div id="tasks"></div>
    </div>
    <!--Script-->
    <script src="script.js"></script>
</body>
</html>

CSS:

Next, we style this app to give it a sleek and modern look by adding CSS. For this copy, the code provided to you below and paste it into your stylesheet.

*,
*:before,
*:after{
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}
body{
    height: 100vh;
    background: linear-gradient(
        135deg,
        #8052ec,
        #d161ff
    );
}
.container{
    width: 40%;
    min-width: 450px;
    position: absolute;
    margin: auto;
    left: 0;
    right: 0;
    top: 30px;
    padding: 30px 40px;
}
#newtask{
    position: relative;
    background-color: #ffffff;
    padding: 30px 20px;
    border-radius: 5px;
    box-shadow: 0 15px 30px rgba(0,0,0,0.3);
}
#newtask input{
    width: 70%;
    width: 70%;
    height: 45px;
    font-family: 'Poppins',sans-serif;
    font-size: 15px;
    border: 2px solid #d1d3d4;
    padding: 12px;
    color: #111111;
    font-weight: 500;
    position: relative;
    border-radius: 5px;
}
#newtask input:focus{
    outline: none;
    border-color: #8052ec;
}

#newtask button{
    position: relative;
    float: right;
    width: 20%;
    height: 45px;
    border-radius: 5px;
    font-family: 'Poppins',sans-serif;
    font-weight: 500;
    font-size: 16px;
    background-color: #8052ec;
    border: none;
    color: #ffffff;
    cursor: pointer;
    outline: none;
}
#tasks{
    background-color: #ffffff;
    padding: 30px 20px;
    margin-top: 60px;
    border-radius: 10px;
    box-shadow: 0 15px 30px rgba(0,0,0,0.3);
    width: 100%;
    position: relative;
}
.task{
    background-color: #ffffff;
    height: 50px;
    padding: 5px 10px;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #d1d3d4;
    cursor: pointer;
}
.task span{
    font-family: 'Poppins',sans-serif;
    font-size: 15px;
    font-weight: 400;
}
.task button{
    background-color: #8052ec;
    color: #ffffff;
    height: 100%;
    width: 40px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    outline: none;
}
.completed{
    text-decoration: line-through;
}

Javascript:

Finally, we add logic and functionality to this app using Javascript. We do this in five easy steps:

  1. Validate input field
  2. Add a new task
  3. Deleting a task
  4. Crossing out a completed task
  5. Clearing the input field after each entry

Create Instagram Logo Using HTML And CSS

document.querySelector('#push').onclick = function(){
    if(document.querySelector('#newtask input').value.length == 0){
        alert("Please Enter a Task")
    }
    else{
        document.querySelector('#tasks').innerHTML += `
            <div class="task">
                <span id="taskname">
                    ${document.querySelector('#newtask input').value}
                </span>
                <button class="delete">
                    <i class="far fa-trash-alt"></i>
                </button>
            </div>
        `;

        var current_tasks = document.querySelectorAll(".delete");
        for(var i=0; i<current_tasks.length; i++){
            current_tasks[i].onclick = function(){
                this.parentNode.remove();
            }
        }

        var tasks = document.querySelectorAll(".task");
        for(var i=0; i<tasks.length; i++){
            tasks[i].onclick = function(){
                this.classList.toggle('completed');
            }
        }

        document.querySelector("#newtask input").value = "";
    }
}

That’s it for this tutorial. If face any issues while creating this project you can download the source code by clicking on the ‘Download Code’ button below. Also if you have any queries, suggestions or feedback do comment below.
Happy Coding!

Download Code
  • Tags
  • easy js projects
  • javascrip project
  • javascript mini project
  • javascript to do list
  • javascript tutorial
  • simple to do list javascript
  • to do list with javascript
Facebook
Twitter
Pinterest
WhatsApp
Previous article Heart Loading Animation With CSS
Next article CSS Single Div Art | CSS Tutorial
Coding Artist
RELATED ARTICLES
Javascript

Barcode Generator | Javascript Project With Source Code

CSS

Dynamic color changer

CSS

Fruit Fall Game Javascript

  • Hi, CodingArtist!
    I have a question because I do not know what meaning this row:
    ${document.querySelector(‘#newtask input’).value}
    Could you help me?
    Thanks 馃檪

    Reply
  • thanks

    Reply
  • LEAVE A REPLY Cancel reply

    Please enter your comment!
    Please enter your name here

    16 − 15 =

    Most Popular

    Barcode Generator | Javascript Project With Source Code

    Dynamic color changer

    Fruit Fall Game Javascript

    Shake On Invalid Input | HTML, CSS & Javascript

    Load more

    两个鬼故事姓关起个名字毒龙是什么意思火柴人联盟破解版琅琊榜之风起长林下载设计工作室的起名美山兰子鬼作如何给自己起网名李佳开头起名男孩幼小衔接班起名比较洋气的男孩起名赵新水浒传分集剧情开包子店起名大白鲨大报复魔兽火影地图罗宝宝起名大全大全美容起名大全集参考医疗器械公司起什么名字男情难了哪个返利网返利最高绿舌头用木字起名外交部提醒中国公民尽早离开阿富汗广州区号装修公司哪家好情人节动态图片黎起什么名字好听斗罗大陆四终极斗罗小说免费阅读姓 马 起名大全五行多缺火起名字少年生前被连续抽血16次?多部门介入两大学生合买彩票中奖一人不认账让美丽中国“从细节出发”淀粉肠小王子日销售额涨超10倍高中生被打伤下体休学 邯郸通报单亲妈妈陷入热恋 14岁儿子报警何赛飞追着代拍打雅江山火三名扑火人员牺牲系谣言张家界的山上“长”满了韩国人?男孩8年未见母亲被告知被遗忘中国拥有亿元资产的家庭达13.3万户19岁小伙救下5人后溺亡 多方发声315晚会后胖东来又人满为患了张立群任西安交通大学校长“重生之我在北大当嫡校长”男子被猫抓伤后确诊“猫抓病”测试车高速逃费 小米:已补缴周杰伦一审败诉网易网友洛杉矶偶遇贾玲今日春分倪萍分享减重40斤方法七年后宇文玥被薅头发捞上岸许家印被限制高消费萧美琴窜访捷克 外交部回应联合利华开始重组专访95后高颜值猪保姆胖东来员工每周单休无小长假男子被流浪猫绊倒 投喂者赔24万小米汽车超级工厂正式揭幕黑马情侣提车了西双版纳热带植物园回应蜉蝣大爆发当地回应沈阳致3死车祸车主疑毒驾恒大被罚41.75亿到底怎么缴妈妈回应孩子在校撞护栏坠楼外国人感慨凌晨的中国很安全杨倩无缘巴黎奥运校方回应护栏损坏小学生课间坠楼房客欠租失踪 房东直发愁专家建议不必谈骨泥色变王树国卸任西安交大校长 师生送别手机成瘾是影响睡眠质量重要因素国产伟哥去年销售近13亿阿根廷将发行1万与2万面值的纸币兔狲“狲大娘”因病死亡遭遇山火的松茸之乡“开封王婆”爆火:促成四五十对奥巴马现身唐宁街 黑色着装引猜测考生莫言也上北大硕士复试名单了德国打算提及普京时仅用姓名天水麻辣烫把捣辣椒大爷累坏了

    两个鬼故事 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化