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

177
Visualizações
How to show a div when the enter key has been pressed in two textareas?

How do you detect that the enter key was pressed in two textareas? I have a way to detect the enter key was pressed in one textarea and need help with detecting the enter key was pressed in two textareas.

This is what I've done so far:

$('#test1').keyup(function(e) {
   if(e.keyCode == 13) {
        $("#GFG_DOWN").text("Enter key pressed inside textarea");
   }
});  
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<textarea id="test1"></textarea>
        <textarea id="test2"></textarea>
        <br>     
          
        <p id = "GFG_DOWN" style = 
            "color:green; font-size: 20px; font-weight: bold;">
        </p>

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

0

I guess you must handle this with two FlagVariables.

let text1Flag = false;
let text2Flag = false;

function callbackHandler(e, textType) {
   if(e.keyCode == 13) {
        if (textType == 1) {
            text1Flag = true;
        } else {
            text2Flag = true;
        }
        if (text1Flag && text2Flag) {
           $("#GFG_DOWN").text("Enter key pressed inside textarea");
            text1Flag = false;
            text2Flag = false;
        }
   }
}

$("#test1").keyup((ev) => callbackHandler(ev, 1));
$("#test2").keyup((ev) => callbackHandler(ev, 2));
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<textarea id="test1"></textarea>
        <textarea id="test2"></textarea>
        <br>     
          
        <p id = "GFG_DOWN" style = 
            "color:green; font-size: 20px; font-weight: bold;">
        </p>

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