0

I'm trying to focus an anchor tag

However when I console.log the result the length is 0

here is the tag:

<a href="#Test/686" data-item-type="Test" data-item-id="686" class="someclass">View</a>

I've tried focusing it by:

console.log($("#data-item-id[686]").focus());

however, it does not work as the length of the output is 0. Any suggestions?

rahulchawla
  • 152
  • 1
  • 1
  • 16
  • You're using an `id` selector in an attempt to select an element by a `data` attribute. You need to use an attribute selector instead: `$('[data-item-id="686"]')` – Rory McCrossan Oct 21 '21 at 19:22

0 Answers0