任何人都可以帮助从我的向下箭头键事件中找到下一个可见列表标签?jquery如何找到下一个可见列表标签
HTML:
<ul class="langCountryListLeftPanel" data-bind="foreach: myLangListViewModel.CommonList">
<li style="display: none;">
<span class="chkboxStyle01 chkboxStyle01Normal columnLeft">⬛</span>
<a tabindex="20" class="columnLeft" data-bind="html:$data, click: myLangListViewModel.showCountryList">Pashto</a>
</li>
<li>
<span class="chkboxStyle01 chkboxStyle01Normal columnLeft">⬛</span>
<a tabindex="20" class="columnLeft" data-bind="html:$data, click: myLangListViewModel.showCountryList">Dari</a>
</li>
<li style="display: none;">
<span class="chkboxStyle01 chkboxStyle01Normal columnLeft"> </span>
<a tabindex="20" class="columnLeft" data-bind="html:$data, click: myLangListViewModel.showCountryList">Albanian</a>
</li>
<li>
<span class="chkboxStyle01 chkboxStyle01Normal columnLeft">⬛</span>
<a tabindex="20" class="columnLeft" data-bind="html:$data, click: myLangListViewModel.showCountryList">Dutch</a>
</li>
<li style="display: none;">
<span class="chkboxStyle01 chkboxStyle01Normal columnLeft"> </span>
<a tabindex="20" class="columnLeft" data-bind="html:$data, click: myLangListViewModel.showCountryList">French</a>
</li>
<li style="display: none;">
<span class="chkboxStyle01 chkboxStyle01Normal columnLeft"> </span>
<a tabindex="20" class="columnLeft" data-bind="html:$data, click: myLangListViewModel.showCountryList">German</a>
</li>
<li>
<span class="chkboxStyle01 chkboxStyle01Normal columnLeft"> </span>
<a tabindex="20" class="columnLeft" data-bind="html:$data, click: myLangListViewModel.showCountryList">English</a>
</li>
<li>
<span class="chkboxStyle01 chkboxStyle01Normal columnLeft">⬛</span>
<a tabindex="20" class="columnLeft" data-bind="html:$data, click: myLangListViewModel.showCountryList">Danish</a>
</li>
</ul>
JS:
$('.langCountryListLeftPanel li a').keydown(function (e) {
// For keyboard shortcuts for "Down arrow" pressing
if (e.keyCode == 40) {
alert($(this).closest("li").next("li").is(':visible').text());
$(this).closest("li").next("li").find("a").focus();
return false;
}
});
也就是说从上面的HTML结构,当焦点在任何列表标签,从如果我按向下箭头它需要只关注下一个可见列表标记,而不是隐藏列表标记,如何使用jQuery找到下一个可见列表标记或列表标记锚点或文本?任何帮助
Anoop:由于其工作正常,我也更新了:首先,而不是.eq(0),(ie)$(this).closest(“li”)。nextAll(“li:visible:first”)。find(“a”)。和$(this).closest(“li”)。prevAll(“li:visible:first”)。find(“a”)。focus(); – Krish 2014-10-16 10:51:02
Anoop:对不起,我可以知道我的个人资料中有绿色勾号标记吗? – Krish 2014-10-16 11:41:16
为我工作。 – 2017-07-19 10:09:43