首页 > 代码库 > javascript-设置div隐藏
javascript-设置div隐藏
html code:
<div class="title"> <ul id="col02_left_title"> <li><a id="science_danamic" href="#">科研动态</a></li> <li><a id="teach_danamic" href="#">教学动态</a></li> </ul></div><div class="content"> <!--<iframe id="col02_left_content" scrolling="no" target="_parent" class="content_frame" src="http://www.mamicode.com/content/科研动态.html"></iframe>--> <div id="col02_left_content" class="content_frame"> <div id="science_show" class="dynamic_show">科研动态-内容</div> <div id="teach_show">教学动态-内容</div> </div></div>
css:
.dynamic_show { display:block;}.dynamic_hide { display:none;}
javascript:
function set_danamic() { var science_danamic = document.getElementById(‘science_danamic‘); var science_show = document.getElementById(‘science_show‘); var teach_danamic = document.getElementById(‘teach_danamic‘); var teach_show = document.getElementById(‘teach_show‘); teach_show.className = ‘dynamic_hide‘; science_danamic.onmouseover = function () { science_show.className = ‘dynamic_show‘; teach_show.className = ‘dynamic_hide‘; } teach_danamic.onmousemove = function () { teach_show.className = ‘dynamic_show‘; science_show.className = ‘dynamic_hide‘; }}
最后,在 body事件中回调即可:
<body onload="set_danamic()">
javascript-设置div隐藏
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。