当用户从列表框中选择一个项目时,焦点仍然存在,所以如果他按“输入”它仍然存在。我想在挑选后自动改变焦点。
我正在使用这个jquery函数:
$(function() {
$("nextStep").focus();
});
“nextStep”是按钮的类,它可以工作,但我想在组合框架aria-expanded的属性为false时实现。你能解释一下我该怎么办?
这是列表框:
<button type="button" class="btn dropdown-toggle btn-default"
data-toggle="dropdown" role="button" data-id="tn_workType"
title="Disoccupato" aria-expanded="false">
<span class="filter-option pull-left">Disoccupato</span>
<span class="bs-caret">
<span class="caret"></span>
</span>
</button>
这是nextStep按钮:
<a href="javascript:void(0)" class="btn btn-white btn-rounded nextStep"
tabindex="0">Avanti →</a>
答案 0 :(得分:0)
$(function() {
$('select').change(function (e) {
$('.nextStep').focus();
});
$('.nextStep').click(function(){
alert("Avanti buttonn clicked")
});
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<select class="btn btn-toogle btn-default">
<option>Option1</option>
<option>Option2</option>
</select>
When the user choose an item from the list box, the focus remain there, so if he press "enter" it remains there. I'd like to automatically change the focus after the pick.
I'm using this jquery function:
$(function() {
$("nextStep").focus();
});
"nextStep" is the class of the button and it works, but I'd like to make it happen when the attribute of the combobox aria-expanded is false. Can you explain me how can I do this please?
This is the listbox:
This is the nextStep button:
<a href="javascript:void(0)" class="btn btn-white btn-rounded nextStep"
tabindex="0">Avanti →</a>
&#13;