Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
HTML, Pure Javascript | How to make an element follow the text freshly entered

I am trying to create an effect in which a circle follows the new entered text

Like: As I type 'H', the circle is behind it, then when I press 'e', the text now visible is 'He' but the circle is behind 'e' now. And this process continues.

The text will be entered in a <textarea> and this text coveres half the page.

This is a website and If possible please give the answers with HTML, CSS and Vanilla JS as I haven't learnt JQuery or any other Framwork, Library, etc.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In a textarea element I think it is not possible without further ado. But you can use an input element instead. I have built a small prototype that shows you how to do it.

const op = document.querySelector('.output');

function make() {
  const ta = document.querySelector('#textarea input');  
  op.innerHTML = ta.value;
  const nw = ta.value.length < 1 ? 1: ta.value.length;
  
   ta.size= parseInt(nw);
}
.w {
  text-align: center;
}

.output {
  background: lightgray;
  font-size: 10px;
  border-radius: 25px;
  padding:5px;
  margin-bottom: auto;
}

#textarea{
  border:1px solid #eee;
  display: flex;
  gap: 10px;
}

#textarea input{  
  border:none;
  background:none;
  font-size:1.2em;
  padding:6px;
}

#textarea input:focus{
   outline:none;
}
  <div id="textarea" oninput="make()">
    <input size="1" type="text" value=""/>
    <div class="output"></div>  
   </div> 
  

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda