Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • GfG 160: Daily DSA
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • JS Tutorial
  • JS Exercise
  • JS Interview Questions
  • JS Array
  • JS String
  • JS Object
  • JS Operator
  • JS Date
  • JS Error
  • JS Projects
  • JS Set
  • JS Map
  • JS RegExp
  • JS Math
  • JS Number
  • JS Boolean
  • JS Examples
  • JS Free JS Course
  • JS A to Z Guide
  • JS Formatter
Open In App
Next Article:
Todo List App Using JavaScript
Next article icon

Todo List App Using JavaScript

Last Updated : 06 Feb, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

This To-Do List app helps users manage tasks with features like adding, editing, and deleting tasks. By building it, you'll learn about DOM manipulation, localStorage integration, and basic JavaScript event handling.

What We Are Going To Create

We are creating a Todo application where

  • Users can add, edit (toggle between "Edit" and "Save"), and delete tasks dynamically.
  • Tasks are stored in local Storage for persistence, and the layout is responsive across devices.
  • Custom CSS with hover effects and animations ensures a sleek, user-friendly experience.

Project Preview

Screenshot-2025-01-21-172254
JavaScript Project on Todo List

Todo List App - HTML and CSS code

This HTML structure creates the basic layout for a to-do list app, providing an input field for new tasks, an "Add" button, and a container to display the task list.

HTML
<html>
<head>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background: linear-gradient(135deg, #f06, #4a90e2);
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            color: #fff;
        }
        .container {
            background: rgba(255, 255, 255, 0.1);
            padding: 2rem;
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            width: 100%;
            max-width: 400px;
        }
        input[type="text"] {
            width: calc(100% - 100px);
            padding: 0.8rem;
            border-radius: 8px;
            border: none;
            outline: none;
            font-size: 1rem;
            margin-right: 1rem;
            box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
        }
        button {
            padding: 0.8rem 1rem;
            border-radius: 8px;
            border: none;
            background: #ff6b6b;
            color: #fff;
            font-size: 1rem;
            cursor: pointer;
            transition: background 0.3s;
        }
        button:hover {
            background: #ff4757;
        }
        .todo {
            background: rgba(255, 255, 255, 0.2);
            border-radius: 8px;
            margin-top: 1rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0.8rem;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            transition: transform 0.2s, background 0.3s;
        }
        .todo:hover {
            transform: translateY(-3px);
            background: rgba(255, 255, 255, 0.3);
        }
        .task {
            flex: 1;
            font-size: 1rem;
            cursor: pointer;
        }
        .delete,
        .edit {
            cursor: pointer;
            transition: transform 0.2s, color 0.3s;
        }
        .delete:hover {
            transform: scale(1.1);
            color: #ff4757;
        }
        .edit:hover {
            transform: scale(1.1);
            color: #1e90ff;
        }
        svg {
            fill: currentColor;
        }
    </style>
</head>
<body>
    <div class="container">
        <input type="text" placeholder="Add a new task...">
        <button>Add</button>
        <div id="task-list"></div>
    </div>
</body>
</html>

In this example

  • A text input field and an "Add" button allow users to enter new tasks, all centered within a visually appealing gradient background.
  • Tasks are displayed in rounded, shadowed containers, with hover effects that slightly lift the task and change its background for a dynamic feel.
  • The edit and delete icons have color transitions and scaling effects, making interactions intuitive and visually responsive for better usability.

Todo List App - JavaScript code

This JavaScript code handles the functionality of the to-do list app, including adding tasks, editing, deleting, and saving them in the browser's local storage.

JavaScript
let inputs = document.querySelector('input');
let btn = document.querySelector('button');
let taskList = document.getElementById('task-list');
let task = [];
let localstoragedata = localStorage.getItem("task array");

if (localstoragedata != null) {
    let ogdata = JSON.parse(localstoragedata);
    task = ogdata;
    maketodo();
}

btn.addEventListener("click", function() {
    let query = inputs.value;
    inputs.value = "";
    if (query.trim() === "") {
        alert("no value entered");
        throw new Error("empty input field error");
    }

    let taskObj = {
        id: Date.now(),
        text: query
    }
    task.push(taskObj);
    localStorage.setItem("task array", JSON.stringify(task));
    maketodo();
});

function maketodo() {
    taskList.innerHTML = "";
    for (let i = 0; i < task.length; i++) {
        let { id, text } = task[i];
        let element = document.createElement('div');
        element.innerHTML = `
            <span class="task" contenteditable="false">${text}</span>
            <button class='edit'>Edit</button>
            <span class="delete"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM18 8H6V20H18V8ZM13.4142 13.9997L15.182 15.7675L13.7678 17.1817L12 15.4139L10.2322 17.1817L8.81802 15.7675L10.5858 13.9997L8.81802 12.232L10.2322 10.8178L12 12.5855L13.7678 10.8178L15.182 12.232L13.4142 13.9997ZM9 4V6H15V4H9Z"></path></svg></span>
        `;
        let delbtn = element.querySelector('.delete');
        let editbtn = element.querySelector('.edit');
        let taskText = element.querySelector('.task');

        // Delete Task
        delbtn.addEventListener("click", function() {
            let filteredarray = task.filter(function(taskobj) {
                return taskobj.id != id;
            });
            task = filteredarray;
            localStorage.setItem("task array", JSON.stringify(task));
            taskList.removeChild(element);
        });

        // Edit Task
        editbtn.addEventListener("click", function() {
            if (editbtn.innerText === 'Edit') {
                taskText.setAttribute('contenteditable', 'true'); // Enable editing
                taskText.focus(); // Focus on the text to start editing
                editbtn.innerText = 'Save'; // Change button text to 'Save'
            } else {
                taskText.setAttribute('contenteditable', 'false'); // Disable editing
                let updatedText = taskText.innerText.trim();
                if (updatedText !== "") {
                    task = task.map(function(taskobj) {
                        if (taskobj.id === id) {
                            taskobj.text = updatedText;
                        }
                        return taskobj;
                    });
                    localStorage.setItem("task array", JSON.stringify(task));
                }
                editbtn.innerText = 'Edit'; // Change button text back to 'Edit'
            }
        });

        element.classList.add('todo');
        taskList.appendChild(element);
    }
}

In this example

  • Selects the input field, button, and task list; retrieves stored tasks from localStorage and populates the task array.
  • Reads and trims input, creates a task object, updates localStorage, and re-renders tasks; shows an alert for empty input.
  • Uses the maketodo function to generate a styled task list with text, edit, and delete buttons.
  • Removes the task from the task array, updates localStorage, and deletes it from the DOM.
  • Toggles between "Edit" and "Save", allows inline text editing, updates localStorage, and refreshes the task list.

Complete code

HTML
<html>
<head>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background: linear-gradient(135deg, #f06, #4a90e2);
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            color: #fff;
        }
        .container {
            background: rgba(255, 255, 255, 0.1);
            padding: 2rem;
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            width: 100%;
            max-width: 400px;
        }
        input[type="text"] {
            width: calc(100% - 100px);
            padding: 0.8rem;
            border-radius: 8px;
            border: none;
            outline: none;
            font-size: 1rem;
            margin-right: 1rem;
            box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
        }
        button {
            padding: 0.8rem 1rem;
            border-radius: 8px;
            border: none;
            background: #ff6b6b;
            color: #fff;
            font-size: 1rem;
            cursor: pointer;
            transition: background 0.3s;
        }
        button:hover {
            background: #ff4757;
        }
        .todo {
            background: rgba(255, 255, 255, 0.2);
            border-radius: 8px;
            margin-top: 1rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0.8rem;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            transition: transform 0.2s, background 0.3s;
        }
        .todo:hover {
            transform: translateY(-3px);
            background: rgba(255, 255, 255, 0.3);
        }
        .task {
            flex: 1;
            font-size: 1rem;
            cursor: pointer;
        }
        .delete,
        .edit {
            cursor: pointer;
            transition: transform 0.2s, color 0.3s;
        }
        .delete:hover {
            transform: scale(1.1);
            color: #ff4757;
        }
        .edit:hover {
            transform: scale(1.1);
            color: #1e90ff;
        }
        svg {
            fill: currentColor;
        }
    </style>
</head>
<body>
    <div class="container">
        <input type="text" placeholder="Add a new task...">
        <button>Add</button>
        <div id="task-list"></div>
    </div>
    <script>
        let inputs = document.querySelector('input');
        let btn = document.querySelector('button');
        let taskList = document.getElementById('task-list');
        let task = [];
        let localstoragedata = localStorage.getItem("task array");
        if (localstoragedata != null) {
            let ogdata = JSON.parse(localstoragedata);
            task = ogdata;
            maketodo();
        }
        btn.addEventListener("click", function () {
            let query = inputs.value;
            inputs.value = "";
            if (query.trim() === "") {
                alert("no value entered");
                throw new Error("empty input field error");
            }
            let taskObj = {
                id: Date.now(),
                text: query
            }
            task.push(taskObj);
            localStorage.setItem("task array", JSON.stringify(task));
            maketodo();
        });
        function maketodo() {
            taskList.innerHTML = "";
            for (let i = 0; i < task.length; i++) {
                let { id, text } = task[i];
                let element = document.createElement('div');
                element.innerHTML = `
                    <span class="task" contenteditable="false">${text}</span>
                    <button class='edit'>Edit</button>
                    <span class="delete"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM18 8H6V20H18V8ZM13.4142 13.9997L15.182 15.7675L13.7678 17.1817L12 15.4139L10.2322 17.1817L8.81802 15.7675L10.5858 13.9997L8.81802 12.232L10.2322 10.8178L12 12.5855L13.7678 10.8178L15.182 12.232L13.4142 13.9997ZM9 4V6H15V4H9Z"></path></svg></span>
                `;
                let delbtn = element.querySelector('.delete');
                let editbtn = element.querySelector('.edit');
                let taskText = element.querySelector('.task');
                delbtn.addEventListener("click", function () {
                    let filteredarray = task.filter(function (taskobj) {
                        return taskobj.id != id;
                    });
                    task = filteredarray;
                    localStorage.setItem("task array", JSON.stringify(task));
                    taskList.removeChild(element);
                });
                editbtn.addEventListener("click", function () {
                    if (editbtn.innerText === 'Edit') {
                        taskText.setAttribute('contenteditable', 'true'); // Enable editing
                        taskText.focus(); // Focus on the text to start editing
                        editbtn.innerText = 'Save'; // Change button text to 'Save'
                    } else {
                        taskText.setAttribute('contenteditable', 'false'); // Disable editing
                        let updatedText = taskText.innerText.trim();
                        if (updatedText !== "") {
                            task = task.map(function (taskobj) {
                                if (taskobj.id === id) {
                                    taskobj.text = updatedText;
                                }
                                return taskobj;
                            });
                            localStorage.setItem("task array", JSON.stringify(task));
                        }
                        editbtn.innerText = 'Edit'; // Change button text back to 'Edit'
                    }
                });
                element.classList.add('todo');
                taskList.appendChild(element);
            }
        }
    </script>
</body>
</html>

Next Article
Todo List App Using JavaScript
author
imsushant12
Improve
Article Tags :
  • Project
  • Technical Scripter
  • JavaScript
  • Web Technologies
  • Technical Scripter 2020
  • JavaScript-Projects

Similar Reads

    Todo list app using Flask | Python
    There are many frameworks that allow building your webpage using Python, like Django, flask, etc. Flask is a web application framework written in Python. Flask is based on WSGI(Web Server Gateway Interface) toolkit and Jinja2 template engine. Its modules and libraries that help the developer to writ
    3 min read
    Todo List Application using MERN
    Todo list web application using MERN stack is a project that basically implements basic CRUD operation using MERN stack (MongoDB, Express JS, Node JS, React JS). The users can read, add, update, and delete their to-do list in the table using the web interface. The application gives a feature to the
    8 min read
    Movie Search Application using JavaScript
    In this article, we are going to make a movie search application using JavaScript. It will use an API which is a RESTful web service to obtain movie information. We will be using HTML to structure our project, CSS for designing purposes and JavaScript will be used to provide the required functionali
    4 min read
    Todo List CLI application using Node.js
    CLI is a very powerful tool for developers. We will be learning how to create a simple Todo List application for command line. We have seen TodoList as a beginner project in web development and android development but a CLI app is something we don't often hear about.Pre-requisites:A recent version o
    13 min read
    How To Build Notes App Using Html CSS JavaScript ?
    In this article, we are going to learn how to make a Notes App using HTML, CSS, and JavaScript. This project will help you improve your practical knowledge in HTML, CSS, and JavaScript. In this notes app, we can save the notes as titles and descriptions in the local storage, so the notes will stay t
    4 min read
    How to Create a Desktop App Using JavaScript?
    Building a JavaScript desktop application is possible using various frameworks and technologies. One popular approach is to use Electron, which is an open-source framework developed by GitHub. Electron allows you to build cross-platform desktop applications using web technologies such as HTML, CSS,
    2 min read
    Uses of JavaScript
    JavaScript is a versatile programming language extensively used in web development. It empowers interactive features like form validation, dynamic content updates, and user interface enhancements. Furthermore, it's employed in server-side scripting, mobile app development, game development, and even
    3 min read
    Todo List Application using MEAN Stack
    The todo list is very important tool to manage our tasks in this hectic schedule. This article explores how to build to-do list application using the MEAN stack—MongoDB, Express.js, Angular, and Node.js. We’ll walk you through the process of setting up backends with Node.js and Express.js, integrati
    10 min read
    How to create a FAQ page using JavaScript ?
    The frequently Asked Questions (FAQ) section is one of the most important sections of any website, especially if you are providing services. If you want to learn how to make it by yourself then welcome! today we'll learn how to create a FAQ page using JavaScript. Functionalities required in a FAQ pa
    6 min read
    Create a Quiz Application Using JavaScript
    In this article, we will learn how to create a quiz application using JavaScript. The quiz application will contain questions followed by a total score shown at the end of the quiz. The score will increase based on the correct answers given. Initially, there are only three questions, but you can inc
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

'); // $('.spinner-loading-overlay').show(); let script = document.createElement('script'); script.src = 'https://assets.geeksforgeeks.org/v2/editor-prod/static/js/bundle.min.js'; script.defer = true document.head.appendChild(script); script.onload = function() { suggestionModalEditor() //to add editor in suggestion modal if(loginData && loginData.premiumConsent){ personalNoteEditor() //to load editor in personal note } } script.onerror = function() { if($('.editorError').length){ $('.editorError').remove(); } var messageDiv = $('
').text('Editor not loaded due to some issues'); $('#suggestion-section-textarea').append(messageDiv); $('.suggest-bottom-btn').hide(); $('.suggestion-section').hide(); editorLoaded = false; } }); //suggestion modal editor function suggestionModalEditor(){ // editor params const params = { data: undefined, plugins: ["BOLD", "ITALIC", "UNDERLINE", "PREBLOCK"], } // loading editor try { suggestEditorInstance = new GFGEditorWrapper("suggestion-section-textarea", params, { appNode: true }) suggestEditorInstance._createEditor("") $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = true; } catch (error) { $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = false; } } //personal note editor function personalNoteEditor(){ // editor params const params = { data: undefined, plugins: ["UNDO", "REDO", "BOLD", "ITALIC", "NUMBERED_LIST", "BULLET_LIST", "TEXTALIGNMENTDROPDOWN"], placeholderText: "Description to be......", } // loading editor try { let notesEditorInstance = new GFGEditorWrapper("pn-editor", params, { appNode: true }) notesEditorInstance._createEditor(loginData&&loginData.user_personal_note?loginData.user_personal_note:"") $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = true; } catch (error) { $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = false; } } var lockedCasesHtml = `You can suggest the changes for now and it will be under 'My Suggestions' Tab on Write.

You will be notified via email once the article is available for improvement. Thank you for your valuable feedback!`; var badgesRequiredHtml = `It seems that you do not meet the eligibility criteria to create improvements for this article, as only users who have earned specific badges are permitted to do so.

However, you can still create improvements through the Pick for Improvement section.`; jQuery('.improve-header-sec-child').on('click', function(){ jQuery('.improve-modal--overlay').hide(); $('.improve-modal--suggestion').hide(); jQuery('#suggestion-modal-alert').hide(); }); $('.suggest-change_wrapper, .locked-status--impove-modal .improve-bottom-btn').on('click',function(){ // when suggest changes option is clicked $('.ContentEditable__root').text(""); $('.suggest-bottom-btn').html("Suggest changes"); $('.thank-you-message').css("display","none"); $('.improve-modal--improvement').hide(); $('.improve-modal--suggestion').show(); $('#suggestion-section-textarea').show(); jQuery('#suggestion-modal-alert').hide(); if(suggestEditorInstance !== null){ suggestEditorInstance.setEditorValue(""); } $('.suggestion-section').css('display', 'block'); jQuery('.suggest-bottom-btn').css("display","block"); }); $('.create-improvement_wrapper').on('click',function(){ // when create improvement option clicked then improvement reason will be shown if(loginData && loginData.isLoggedIn) { $('body').append('
'); $('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.unlocked-status--improve-modal-content').css("display","none"); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { showErrorMessage(e.responseJSON,e.status) }, }); } else { if(loginData && !loginData.isLoggedIn) { $('.improve-modal--overlay').hide(); if ($('.header-main__wrapper').find('.header-main__signup.login-modal-btn').length) { $('.header-main__wrapper').find('.header-main__signup.login-modal-btn').click(); } return; } } }); $('.left-arrow-icon_wrapper').on('click',function(){ if($('.improve-modal--suggestion').is(":visible")) $('.improve-modal--suggestion').hide(); else{ } $('.improve-modal--improvement').show(); }); const showErrorMessage = (result,statusCode) => { if(!result) return; $('.spinner-loading-overlay:eq(0)').remove(); if(statusCode == 403) { $('.improve-modal--improve-content.error-message').html(result.message); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); return; } } function suggestionCall() { var editorValue = suggestEditorInstance.getValue(); var suggest_val = $(".ContentEditable__root").find("[data-lexical-text='true']").map(function() { return $(this).text().trim(); }).get().join(' '); suggest_val = suggest_val.replace(/\s+/g, ' ').trim(); var array_String= suggest_val.split(" ") //array of words var gCaptchaToken = $("#g-recaptcha-response-suggestion-form").val(); var error_msg = false; if(suggest_val != "" && array_String.length >=4){ if(editorValue.length { jQuery('.ContentEditable__root').focus(); jQuery('#suggestion-modal-alert').hide(); }, 3000); } } document.querySelector('.suggest-bottom-btn').addEventListener('click', function(){ jQuery('body').append('
'); jQuery('.spinner-loading-overlay').show(); if(loginData && loginData.isLoggedIn) { suggestionCall(); return; } // script for grecaptcha loaded in loginmodal.html and call function to set the token setGoogleRecaptcha(); }); $('.improvement-bottom-btn.create-improvement-btn').click(function() { //create improvement button is clicked $('body').append('
'); $('.spinner-loading-overlay').show(); // send this option via create-improvement-post api jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { showErrorMessage(e.responseJSON,e.status); }, }); });
"For an ad-free experience and exclusive features, subscribe to our Premium Plan!"
Continue without supporting
`; $('body').append(adBlockerModal); $('body').addClass('body-for-ad-blocker'); const modal = document.getElementById("adBlockerModal"); modal.style.display = "block"; } function handleAdBlockerClick(type){ if(type == 'disabled'){ window.location.reload(); } else if(type == 'info'){ document.getElementById("ad-blocker-div").style.display = "none"; document.getElementById("ad-blocker-info-div").style.display = "flex"; handleAdBlockerIconClick(0); } } var lastSelected= null; //Mapping of name and video URL with the index. const adBlockerVideoMap = [ ['Ad Block Plus','https://media.geeksforgeeks.org/auth-dashboard-uploads/abp-blocker-min.mp4'], ['Ad Block','https://media.geeksforgeeks.org/auth-dashboard-uploads/Ad-block-min.mp4'], ['uBlock Origin','https://media.geeksforgeeks.org/auth-dashboard-uploads/ub-blocke-min.mp4'], ['uBlock','https://media.geeksforgeeks.org/auth-dashboard-uploads/U-blocker-min.mp4'], ] function handleAdBlockerIconClick(currSelected){ const videocontainer = document.getElementById('ad-blocker-info-div-gif'); const videosource = document.getElementById('ad-blocker-info-div-gif-src'); if(lastSelected != null){ document.getElementById("ad-blocker-info-div-icons-"+lastSelected).style.backgroundColor = "white"; document.getElementById("ad-blocker-info-div-icons-"+lastSelected).style.borderColor = "#D6D6D6"; } document.getElementById("ad-blocker-info-div-icons-"+currSelected).style.backgroundColor = "#D9D9D9"; document.getElementById("ad-blocker-info-div-icons-"+currSelected).style.borderColor = "#848484"; document.getElementById('ad-blocker-info-div-name-span').innerHTML = adBlockerVideoMap[currSelected][0] videocontainer.pause(); videosource.setAttribute('src', adBlockerVideoMap[currSelected][1]); videocontainer.load(); videocontainer.play(); lastSelected = currSelected; }

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences