Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
Cómo deshabilitar los saltos de línea en el área de texto en foco

Así que tengo un cuadro de texto (entrada) y le he agregado una funcionalidad que si el usuario presiona Intro, el enfoque cambia a un elemento de área de texto. Pero por alguna razón, se agrega un salto de línea después de enfocar el área de texto y aparece el cursor. Intenté usar (keydown.enter)="$event.preventDefault()" en el área de texto, pero solo evita los saltos de línea cuando el cursor está en el área de texto. ¿Cómo me aseguro de que no se agreguen saltos de línea en el área de texto en foco?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Espero entender sus requisitos exactamente.

Dos cosas que tenemos que lograr para su requerimiento.

1, deshabilitado presione enter en textarea

 $('textarea').keypress(function(e){ if ( e.which == 13 ) e.preventDefault(); });

2, presione la tecla shift para disparar, implementamos al enfocar el siguiente elemento

 $("#next_element").focus();

código final como a continuación

 $('textarea').keypress(function(e){ if ( e.which == 13 ){ $("#next_element").focus(); e.preventDefault(); } });
 <html> <head> <title>Textarea</title> </head> <body> <form action="javascript:void(0);" method="post"> <textarea name="description" placeholder="Description" required></textarea> <input type="text" id="next_element" placeholder="Next element" required /> <input type="submit" /> </form> <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script> </body> </html>

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!