您的位置:首页 > Web前端 > JavaScript

js小实例(显示或隐藏)

2008-12-01 11:37 253 查看
<!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>

<title>点击显示或隐藏</title>

<style type="text/css">

.dis{display:block;}

.non{display:none;}

</style>

<script type="text/javascript">

function f(oid){

var d = document.getElementById(oid);

if(d.className == "non")

d.className = "dis";

else

d.className = "non";

}

</script>

</head>

<body>

<div onclick="f('d1');">点击隐藏或显示</div>

<div id="d1" class="non">显示或隐藏</div>

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: