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

114
Views
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 answers
Answer question

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 Report

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