jquery 隐藏与显示tr标签示例代码
代码是程序员交流的最好方式 哈哈:
. 代码如下:
<%@ page language="java" import="java.util.*" pageencoding="utf-8"%>
<%
string path = request.getcontextpath();
string basepath = request.getscheme()+"://"+request.getservername()+":"+request.getserverport()+path+"/";
%>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en">
<html>
<head>
<base href="<%=basepath%>">
<title>my jsp 'index.' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" src="js/jquery-1.8.2.js"></script>
<script type="text/javascript">
function selectchange(obj){
var value=obj.value;
var v1 = document.getelementbyid("tr1");
var v2 = document.getelementbyid("tr2");
if(value==0){
console.log("two is hidden");
v1.style.display="none";
v2.style.display="none";
}else if(value==1){
v1.style.display="block";
v2.style.display="none";
}else{
v1.style.display="none";
v2.style.display="block";
//将里面的值设为空
}
}
</script>
</head>
<center>
<body >
<form action="getjspcontent" method="post">
<table>
<tr>
<td>通知标题</td>
<td><input type="text" name="title"/></td>
</tr>
<tr>
<td>通知内容</td>
<td><textarea cols="50" rows="10" name="cxt" >内容这块暂时没处理,本次测试用例 需要10个汉字以上测试</textarea></td>
</tr>
<tr>
<td>通知类型</td><td><select onchange="selectchange(this)">
<option value="0" select="true">所有用户</option>
<option value="1">用户组</option>
<option value="2">单用户</option>
</select></td>
</tr>
<tr id="tr1" style="display:none">
<td> 输入标签:</td><td><input type="text" id="tag1" name="tag"></td>
</tr>
<tr id="tr2" style="display:none">
<td> 输入号码:</td><td><input type="text" id="phone" name="phone"></td>
</tr>
<tr>
<td><input type="submit"/></td>
<td><input type="reset"/></td>
</tr>
</table>
</form>
</body>
</center>
</html>
实现效果如下:
上一篇: 还好意思报警
下一篇: 怎么你喝啤酒要用吸管呢