How do I skip items when tabbing without using tabindex?

耗尽温柔 提交于 2019-12-03 23:20:49

Set tabindex = "-1" for that control and browser will skip that control from tabbing.

Maybe:

$("#your-calendar-icon").focus(function() {
  $(this).trigger("blur");
);
Diodeus - James MacFarlane

or:

$("#your-calendar-icon").focus(function() {
    $(somethingElse).trigger("focus");
});

Use a div around the calendar icon instead of a link. Then attach your calendar events to the div. By default, the div won't be a tab stop.

As @thetacom says, you can just use another type of element, one that doesn't receive focus. In case you still want to keep some of the tab functionality, you can try SkipOnTab.

SkipOnTab: A jQuery plugin to exempt selected form fields from the forward tab order.

Just add data-skip-on-tab="true" to the date picker icon (or other elements/containers) you want to skip. You can still click to activate the date picker or go back using shift-tab and use the enter key.

See the simple demo and the business case demo.

If it's always going to be the input after the calendar then why not:

$('#your-calendar-icon').focus( function() {
  $(this).next('input').focus();
} );

Personally, I'd say that if it's going to be a plugin you should just make the next element a configuration option that has a default, and specify the default in the docs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!