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

226
Visualizações
Check for a line-break in a div

On my page I use a textarea to input a text and that text is splitted into words and added to a div. At this point there is no problem. The div has a fixed width of 600px and if the text is to long the div starts a new line. Everything pretty normal as far. Now I need to detect, that there was a linebreak, so I can move the text after the linebreak into a new div. Is it somehow possible to detect that linebreak?

I already tried the include() with /n or <br> or <br/>, also the same with matches() and regex expression how many /n are in the text but nothing seems to work. Now the question is: is there even a way to detect that linebreak and if so how would I do that?

Right now I have a javascript function that is called if an input happens in the textarea

<textarea oninput="textfield_handler()" class="form-control" id="tf-input"></textarea>

In the function I check the linebreak with an if-statement

if(lastChild.innerHTML.includes("<br/>"))
{
    console.log("LINE BREAK");
}
about 4 years ago · Juan Pablo Isaza
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