javascript 控制 DIV等html元素的显示和隐藏
1
、编写
js
函数
<script
type="text/javascript">
function display(id){
var
traget=document.getElementById(id);
if(traget.style.display=="none"){
traget.style.display="";
}else{
traget.style.display="none";
}
}
</script>
2.、
要显示
/
隐藏的
html
元素加上
id
属性
<table>
<tr id="menu"
>
<td>
控制这个
tr
的显示
/
隐藏
</td>
</tr>
</table>
3
、添加按钮,链接等触发
js
函数
<input type="button"
onclick="display(
'menu'
)"
value="
显示
/
隐藏
"/>
<a href="#"
onclick="display(
'menu'
)"
>
显示
/
隐藏
</a>
javascript
显示隐藏层
<div id=""
style="display:none;">
广告
</div>
<input type="botton"
onclick="
函数
">
<script
language=javascript>
function
函数
{
if(thisdiv.style.display=='none'){
thisdiv.style.display=""
}
else
thisdiv.style.display="none"
}
</script>
你先给
div
取个
ID=“AA”thisdiv=AA
javascript
隐藏
/
显示表单对象
<SCRIPT
language=javascript>
function expandIt(el) {
whichEl
=document.getElementById(el)
if (whichEl.style.display == 'none')
{
&nbs
相关文档:
被Struts的html:checkBox标签使用的小问题郁闷了两天,今天终于找到了解决的办法。如果大家也遇到同样的问题,可以参考。
1)需求:
当通过菜单进入页面时,页面中的checkbox处于被选中状态,页面提交后forward回本页,对应的checkbox保持提交时的状态,也就是说:如果提交时check ......
1. document.write( " "); 输出语句
2.JS中的注释为//
3.传统的HTML文档顺序是:document- >html- >(head,body)
4.一个浏览器窗口中的DOM顺序是:window- >(navigator,screen,history,location,document)
5.得到表单中元素的名称和值:document.getElementB ......
Java代码
<script language="JavaScript">
function js_show(per_id)
{
window.open('/weihu/person/viewResume.jsp?perID='+per_id, 'resume', 'resizable=yes,menuBar=0,toolBar=0,scrollbars=yes,width=800,height=600,left ......
每一项都是js中的小技巧,但十分的实用!
1.document.write(""); 输出语句
2.JS中的注释为//
3.传统的HTML文档顺序是:document->html->(head,body)
4.一个浏览器窗口中的DOM顺序是:window->(navigator,screen,history,location,document)
5.得到表单中元素的名称和值:document.getElementById("表单中元素的 ......
<!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> JavaScript: xm ......