Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Textarea with overlay: hide text in textarea

I would like to display an overlay over textarea to display formatted input (textarea does not support tags inside). For now I’m able to pass text that inputed into text area to overlay div but I could not hide text in textarea and it bothers:

    overlay = document.getElementById('overlay')
    query_template = document.getElementById('query_template')
    query_template.addEventListener('input', (e) => {
        console.log(query_template.value);
        overlay.innerText = query_template.value;
        query_template.innerHTML = query_template.value;
    })
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        div{
            border:1px solid transparent
        }
        div,
        textarea {
            position: absolute;
            width: 300px;
            height: 200px;
            top: 0;
            left: 0;
            font-size: 1em;
            line-height: 1em;
        }
    </style>
</head>
<body>
<body>
<div class="parent">
    <div id="overlay" style="color: #1a1a1a"></div>
    <textarea id="query_template" style="color: white; background: transparent"></textarea>
</div>
</body>
</body>
</html>

How can I hide text in textarea?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

u can set

textarea{
color:transparent;
} 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading