Many user and programmer need to create an editable div in a web page which will give the facility to the programmer or to the user to insert new text in the textarea of the div and store it to the localStorage of the browser.
So in today's article we are sharing a editable Div using HTML, Venilla JavaScript and we added lot of CSS to design our editable div.
Join Telegram For Fast Updates- Join Now
Join Instagram For Coding Tips & Tricks- Join Now
How this editable do works?
When you click in the area of the additable div converted into the editable form and it gives you the option to insert text, after inserting text then click on the outer area of the dv and it will automatically save your text into your localStorage of your browser and if you refresh this page it will stored in your browser. And you can also change the text of the editable div when you want.
Live Link - Editable Div
Download Code - Click Here
GitHub Repository - Editable Div
HTML Code For Editable Div
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Editable Div - Geeks Help</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
CSS Code For Editable Div to Add Some Design
/* Little bit CSS to add some style to out editable div */
* {
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
.container {
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: rgb(37 17 116);
color: white;
flex-direction: column;
}
JavaScript Code to Add Functionality
// Out JavaScript Code for Editable Div
// Creating a div with javascript
let divElem = document.createElement('div');