如何在div之间制作标签?我正在尝试在div之间切换以用作面板的选择选项。在特定div面板上选项卡时,其边框应变为活动状态。它不起作用,只有浏览器级别的选项卡。这是我到目前为止所尝试的......
<script type="text/javascript">
$(document).ready(function()
{
$("div").keydown(function(e)
{
if (e.which == 9)
{
$(this).css("border","4px solid gray");
}
});
});
</script>
<div id="north"></div>
<div id="west"></div>
<div id="center"></div>
答案 0 :(得分:2)
我想你可以这样做:
$(document).ready(function() {
// ids of divs you want to cycle through
var divs = ["north", "west", "center"];
var startIndex = 0;
$(document).keydown(function(e) {
if (e.which == 9) {
// remove previously applied border
$("div").css("border", "");
$("#" + divs[startIndex]).css("border", "4px solid gray");
startIndex++;
// reset to first one
if(startIndex === divs.length) {
startIndex = 0;
}
}
// prevent "tabbing out" of the document view
return false;
});
});
Demo.(请务必事先点击呈现的页面区域)