Day # 86: Sticky notes



As frontend developers, one of the most recurring tasks that we need to handle is the entering of text by the user. A good exercise to practice this skill is to create any type of app that allows us to create text and to process it to display it in any part of the website.

With that in mind, I decided to create for today’s website an app that creates sticky notes. The procedure here consists of creating elements with that text and display it as autonomous entities throughout our website:

function divStyle(text) {

    let div = document.createElement("div")

    div.className = 'note'

    div.innerHTML = '<div class="details">'+'<h3>'+text+'</h3>'+'</div>'

    div.addEventListener("dblclick", function() {

        div.remove()

    })

    div.setAttribute('style', 'background:'+colors()+'')

    notes.appendChild(div)

}


We also get to practice events in the DOM, like double clicks to remove a particular note and when the user hits the Enter key to generate the text he wants to display as a sticky note.


Comments

Popular posts from this blog

Day # 35: Flip Book

Day # 1: Homepage w/Introduction

Day # 8: Inspiration