Search code examples
javascripthtmlvue.jsfocus

How to disable focus on specific html elements?


I have custom input component in vue js, and in this component i have input and two buttons.when input loose focus, i want to focus on next input, but now it focus on those buttons. finally i should press tab key three times to focus on next input.

Is there any html attribute for disabling focus on some elements? or there is a javascript way?


Solution

  • The tabindex attribute controls tabbing. Set it to -1 and the tab key will not stop on that element.

    <button tabindex="-1">click me</button>