This article describes the method of JS to expand or hide table rows by clicking on mouse. Share it for your reference. The specific implementation method is as follows:
The code copy is as follows:
<!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=utf-8" />
<title>JS implements mouse click to expand/hide table rows</title>
</head>
<body>
<script language="javascript">
function TestBlack(TagName){
var obj = document.getElementById(TagName);
if(obj.style.display==""){
obj.style.display = "none";
}else{
obj.style.display = "";
}
}
</script>
<table cellpacing="0" cellpadding="0">
<tr onclick="TestBlack('divc');">
<td bgcolor="#00CCFF">Click Me!</td>
</tr>
<tr id="divc">
<td bgcolor="#9966FF"></td>
</tr>
</table>
</body>
</html>
I hope this article will be helpful to everyone's JavaScript programming.