This article is an example of JS to achieve the mouse click to expand or hide the table row method. Share to everyone for your reference. The implementation methods are as follows:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<TITLE>JS implement mouse click expand/Hide Table Rows </title>
<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 width= "760" border= "0" cellspacing= "0" cellpadding= "0" >
<tr onclick= "Testblack (' DIVC ');" >
<TD width= "760" height= "bgcolor=" "#00CCFF" >click me!</td>
</tr>
<tr id= "DIVC" >
<TD width= "760" height= "bgcolor=" "#9966FF" ></td>
</tr>
</table>
</body>
I hope this article will help you with your JavaScript programming.