由于它是jQuery插件,因此我只在onInitialized
和onResized
回调中使用jQuery将屏幕外文本节点添加到按钮:
<style>
.offscreen {
position: absolute;
left: -999em;
}
</style>
<button><span></span><span class="offscreen">Go to slide 3</span></button>
<!-- the first span is there by default -->
可能看起来像这样:
let owl = $('.owl-carousel').owlCarousel({
// ...,onInitialized: addDotButtonText,onResized: addDotButtonText
});
function addDotButtonText() {
// loop through each dot element
$('.owl-dot').each(function() {
// remove old text nodes
$(this).find('.offscreen').remove();
// grab its (zero-based) order in the series
let idx = $(this).index() + 1;
// append a span to the button containing descriptive text
$(this).append('<span class="offscreen">Go to slide ' + idx + '</span>');
});
}
Fiddle demo
如果您觉得这些点对屏幕阅读器用户根本没有用,并且可以只使用上一个和下一个按钮(已经可以访问)进行导航,则可以将这些点隐藏在它们中回调并减少不必要的干扰:
$('.owl-dots').attr('aria-hidden','true');
这可能是值得商strategy的策略,因为我们应努力为所有用户提供相同级别的交互。但是,由于屏幕阅读器用户可能一开始就不会使用滑块控件,所以由于所有幻灯片都应始终可读,因此这根本就不是问题。
本文链接:https://www.f2er.com/2808482.html