Text Editor
Text Editor
css
Copy code
body {
font-family: Arial, sans-serif;
background-color: #f3f3f3;
}
.container {
max-width: 600px;
margin: 50px auto;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
}
textarea {
width: 100%;
height: 200px;
margin-bottom: 20px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
display: block;
width: 100%;
padding: 10px;
margin: 0 auto;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
javascript
Copy code
document.getElementById('downloadButton').addEventListener('click', function() {
const text = document.getElementById('textInput').value;
const blob = new Blob([text], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'text_document.txt';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
});