<button type="button" aria-haspopup="dialog" aria-controls="a" onclick="openLayer($('#a'))"> button</button>
<div role="dialog" id="a"><"button type="button">close<"/button></div>
function openLayer(target){
event.preventDefault();
var backFocus = $("[aria-controls='"+target+"']");
$(target).attr("tabindex", 0).attr("aria-hidden", false).show().focus();
$(document).keyup(function(e){
if (e.keyCode == "27"){
console.log(backFocus); // [obeject object]
$(target).attr("tabindex", 1).attr("aria-hidden", true).hide().blur();
}
});
}
我希望目标通过。
如何将焦点集中在“按钮”上?
function myFunction(myElement){
console.log(myElement.id);
console.log( myElement.getAttribute("a"));
}
<button onclick="myFunction(this)" id="text" a="secret">click me</button>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句