Jquery hides and shows the tr tag sample code

  • 2020-03-30 03:13:00
  • OfStack

The best way for programmers to communicate is to go straight to the code.
 
<%@ 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.jsp' 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"; 
//Set the inside value to null
} 
} 
</script> 
</head> 
<center> 
<body > 
<form action="GetJSPContent" method="post"> 
<table> 
<tr> 
<td> Notice the title </td> 
<td><input type="text" name="title"/></td> 
</tr> 
<tr> 
<td> Inform the content </td> 
<td><textarea cols="50" rows="10" name="cxt" > I'm not working on the content , This test case   Need to be 10 More than five Chinese characters </textarea></td> 
</tr> 
<tr> 
<td> Notification type </td><td><select onchange="selectChange(this)"> 
<option value="0" select="true"> All users </option> 
<option value="1"> User groups </option> 
<option value="2"> A single user </option> 
</select></td> 
</tr> 
<tr id="tr1" style="display:none"> 
<td>  Input label: </td><td><input type="text" id="tag1" name="tag"></td> 
</tr> 
<tr id="tr2" style="display:none"> 
<td>  Input number: </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> 

The implementation effect is as follows:
< img SRC = "border = 0 / / files.jb51.net/file_images/article/201406/201406061050112.gif? 201456105027 ">

Related articles: