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

115
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 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