我无法让这个 tabIndex 工作。当我点击它进入的选项卡时,我希望它成为第一个元素(它是一个完成按钮,但不是“按钮”类型)。事实上,当我给它 a.tabIndex = 1; 它做相反的事情,并在正常/默认的标签流中完全跳过。为什么是这样?
var div = document.createElement("div");
div.setAttribute("class", "container");
div.setAttribute("id", "doneCon");
div.style.width = "70px";
div.style.height = "35px";
div.style.overflow = "hidden";
div.style.borderStyle = "solid";
div.style.borderColor = "blue";
div.style.borderRadius = "35px/18px";
div.style.backgroundColor = "white";
div.style.marginLeft = "5px";
div.style.display = "inline-block";
var a = document.createElement("a");
a.setAttribute("href", "#");
a.setAttribute("class", "a container");
a.tabIndex = 1
a.setAttribute("id", "done");
a.style.display = "block";
a.style.fontFamily = "yo2";
a.style.weight = "bold";
a.style.fontSize = "150%";
a.style.paddingTop = "7px";
a.style.textDecoration = "none";
a.style.color = "blue";
a.style.textAlign = "center";
text = document.createTextNode("Done");
a.appendChild(text);
div.appendChild(a);