js控制div显示与隐藏

<!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=gb2312" />
<title>js显示隐藏层</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function showdiv(targetid,objN){

var target=document.getElementById(targetid);
var clicktext=document.getElementById(objN)

if (target.style.display=="block"){
target.style.display="none";
clicktext.innerText="点击查看详细信息";

} else {
target.style.display="block";
clicktext.innerText=‘关闭详细信息信息‘;
}

}
-->
</script>
<style type="text/css">
<!--

body { font: normal 14px "宋体" }

a { text-decoration: none; }

#showtext { cursor: hand; cursor:pointer;}
#showtext2 { cursor: hand; cursor:pointer;}
#contentid { margin-top: 10px; width:100%; border: 1px solid #CCC; background: #F1F1F1; padding: 15px; }
#contentid2 { margin-top: 10px; width: 470px; border: 1px solid #CCC; background: #F1F1F1; padding: 15px; }
.none { display: none; }
-->
</style>
</head>

<body>
<a id="showtext" onClick="showdiv(‘contentid‘,‘showtext‘)">点击查看详细信息</a>
<div id="contentid" class="none">打开的内容</div>
<p></p>
<a id="showtext2" onClick="showdiv(‘contentid2‘,‘showtext2‘)">点击查看详细信息</a>
<div id="contentid2" class="none">1<br />
2.<br />
3.<br />
4.<br />
5.<br />
6. <br />
7.<br />
8. <br />
9.<br />
10.<br />
11.<br />
12. <br />
13.<br />
14. <br />
15.<br />
</div>

</body>

</html>

时间: 2024-08-09 10:41:37

js控制div显示与隐藏的相关文章

js控制tr显示和隐藏

很久没有写代码,最近新接了一个项目,开始记录自己开发过程中遇到的一些问题. 关于js控制tr的显示与隐藏 最开始写法是: <tr id="att" style="display:none;"> <td style="text-align:right;">附件文件:</td> <td> <div id="div_fujian"> <div class="

js中div显示和隐藏钮为什么页面总是跳一下到最上面

<div class="menu_left"> <ul > <li id="t1" style="background-image:url(images/t2.gif);" > <a href="#" id="first" onclick="infoList('first');" >中心动态</a></li> <

js控制div是否显示

<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <style> body,ul,li{ padding:0; margin:0} li { list-style:none; } .lis { wi

jquery之超简单的div显示和隐藏特效demo

闲着无聊,看到某视频网站上讲的DIV显示和隐藏的效果,自己也写了一个. 觉得还是挺简单的. 前端改变世界!嘿嘿,还挺有成就感 <!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/

jquery的div显示和隐藏

<!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-

外贸建站JS控制随机显示内容代码分享

外贸建站JS控制随机显示内容代码分享 <script> $(function(){ $('li[id^=p_]').each(function(){ var this_id = $(this).attr("id"); var id_arr = this_id.split('_'); if(id_arr[1]>9){ $(this).hide(); } }) }) function tryLuck(){ var num=30; var p_list=new Array(

js密码修改显示与隐藏效果

一.添加input框 <form class="login_form"> <input class="password inputpwd" id="oldpwd" name="oldpwd" type="password" placeholder="请输入旧密码" /> <div class="invisible" onclick=&qu

js控制页面显示

两个菜单切换显示页面内容: js控制代码, /** JS初始化 **/ $(document).ready(function() { $('#email_btn').click(function(){ $('.phone_updatepwd,.email_updatepwd').toggle(); if($(this).text() == "使用邮箱重置密码"){ dxbz=false; $(this).html("使用手机重置密码"); }else{ dxbz=t

Js控制Div在浏览器中的高度

//需求是,我需要通过浏览器内容可视化的高度来控制div的高度boxheight(); //执行函数function boxheight(){ //函数:获取尺寸 //获取浏览器窗口高度 var winHeight=0; if (window.innerHeight) winHeight = window.innerHeight; else if ((document.body) && (document.body.clientHeight)) winHeight = document.b