Este artículo describe el método de JS para expandir u ocultar filas de tabla haciendo clic en el mouse. Compártelo para su referencia. El método de implementación específico es el siguiente:
La copia del código es la siguiente:
<! DocType html public "-// w3c // dtd xhtml 1.0 Transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transicional.dtd ">
<html xmlns = "http://www.w3.org/1999/xhtml">
<Evista>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" />
<title> js implementa hacer clic mouse para expandir/ocultar filas de tabla </title>
</ablo>
<Body>
<script language = "javaScript">
función testblack (tagName) {
var obj = document.getElementById (tagName);
if (obj.style.display == "") {
obj.style.display = "Ninguno";
}demás{
obj.style.display = "";
}
}
</script>
<TABLE CELLPACING = "0" CellPadding = "0">
<tr onClick = "testblack ('divc');">
<td bgcolor = "#00ccff"> ¡Haga clic en mí! </td>
</tr>
<tr id = "divc">
<td bgcolor = "#9966ff"> </td>
</tr>
</table>
</body>
</html>
Espero que este artículo sea útil para la programación de JavaScript de todos.