上下选择


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
html,body,div,a{padding:0;margin:0;}
#d{ width:300px; margin:0 auto; border:1px solid #3366FF}
#d a{ text-align:center;;width:300px; color:#000000; text-decoration:none; height:24px; line-height:24px; display:block}
#d a:hover{ background-color:#FF6600}
</style>
<script type="text/javascript">
function domLocation(node){
var left , top , right , bottom;
left = top = right = bottom = 0;
var n = node;
while (n) { left += n.offsetLeft, top += n.offsetTop; n = n.offsetParent; };
right = left + node.offsetWidth; bottom = top + node.offsetHeight;
return {"left":left,"right":right,"top":top,"bottom":bottom,"width":node.offsetWidth,"height":node.offsetHeight}
}


function getEvent(){ //同时兼容ie和ff的写法
if(document.all) return window.event;
func=getEvent.caller;
while(func!=null){
var arg0=func.arguments[0];
if(arg0){
if((arg0.constructor==Event || arg0.constructor ==MouseEvent)
|| (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){
return arg0;
}
}
func=func.caller;
}
return null;
}

var g = function(id){return "string" == typeof id ? document.getElementById(id) : id;},
c = function(tagName){return document.createElement(tagName);},
apc = function(o,po){ (po || document.body).appendChild(o);};


function isF60(a){
var bgc = a.currentStyle ? a.currentStyle["backgroundColor"] : window.getComputedStyle(a, null)["backgroundColor"];
if(bgc.toLowerCase() == "#ff6600" || ("rgb(255,102,0)" == bgc.replace(/\s+/ig,"")))
return true;
else
return false;
}
var cs,idx
function toggelKey(upDownFlag){
var f60flag = false;
for(var i = 0; i < cs.length; i++){

if(isF60(cs[i])){
f60flag = true;
idx = upDownFlag ? i-1 : i+1;
}
cs[i].style.backgroundColor = "";
}
if((!f60flag || idx == -1) && upDownFlag) idx = cs.length-1;
else if((!f60flag || idx == cs.length) && !upDownFlag) idx = 0;
cs[idx].style.backgroundColor = "#ff6600";
}


function ku(){
var e = getEvent();
if(e.keyCode == 38) toggelKey(true);
else if(e.keyCode == 40) toggelKey(false);
else if(e.keyCode == 13) cs[idx].focus();
}

window.onload = function(){
cs = g("d").childNodes
}

</script>
</head>
<body>
<input type="text" onkeyup="ku()">
<div id="d"><a href="javascript:" onfocus="alert(1)">1111111</a><a href="javascript:" onfocus="alert(2)">2222222</a><a href="javascript:" onfocus="alert(3)">3333333</a><a href="javascript:" onfocus="alert(4)">4444444</a><a href="javascript:" onfocus="alert(5)">5555555</a></div>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值