Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

116
Vistas
Focus an element given an html input tag? Jquery

I have an html tag "tabbedCell" returned which can be viewed below:

<input type="text" data-row-id="12630" class="edit numeric ui-draggable ui-draggable-handle" data-field="May" value="135" style="position: relative; cursor: cell;">

I'm trying to set focus on this element, however I have confirmed the focused element is undefined after setting focus. Any suggestions?

EDIT: There are multiple inputs on my page so the answers would not work. I need to focus this specific input element if multiple exist.

console.log(tabbedCell)
$(tabbedCell).focus();
console.log(($(':focus')[0]));
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Add id="sample_input"

<input type="text" id="sample_input" data-row-id="12630" class="edit numeric ui-draggable ui-draggable-handle" data-field="May" value="135" style="position: relative; cursor: cell;">

This is how you focus
# -> Means id

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

Edit: Since you dont want to add another id use this:

$("input[data-row-id=12630]").focus();

Edit 2: like this

$("input[data-row-id=12630][data-field=May]").focus();
about 4 years ago · Juan Pablo Isaza Denunciar

0

Use an ID or Class of the element instead, like here you can use "edit".

$(".edit").focus();
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda