关于div显示隐藏的脚本编写
发布网友
发布时间:2022-04-24 20:54
我来回答
共1个回答
热心网友
时间:2022-04-24 22:23
你要这是这种效果么?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
var a=0;
function _saveInfo(){
if(a==0){
document.getElementById("div").style.display="none";
alert("你键盘输入了回车!");
a++;
}else{
document.getElementById("div").style.display="block";
a--;
}
}
function document_onkeypress(){
switch (event.keyCode) {
case 13: _saveInfo();//捕捉回车符
}
}
</SCRIPT><SCRIPT LANGUAGE=javascript FOR=document EVENT=onkeypress>document_onkeypress()</SCRIPT>
</head>
<body onload="document_onkeypress()">
<div id="div" >Test div dispaly</div>
</body>
</html>