บทความนี้อธิบายวิธีการของ JS เพื่อขยายหรือซ่อนแถวตารางโดยคลิกที่เมาส์ แบ่งปันสำหรับการอ้างอิงของคุณ วิธีการใช้งานเฉพาะมีดังนี้:
การคัดลอกรหัสมีดังนี้:
<! 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 ใช้เมาส์คลิกเพื่อขยาย/ซ่อนแถวตาราง </title>
</head>
<body>
<ภาษาสคริปต์ = "JavaScript">
ฟังก์ชั่น testblack (tagname) {
var obj = document.getElementById (tagname);
if (obj.style.display == "") {
obj.style.display = "ไม่มี";
}อื่น{
obj.style.display = "";
-
-
</script>
<table cellpacing = "0" cellpadding = "0">
<tr onclick = "testblack ('divc');">
<td bgcolor = "#00ccff"> คลิกฉัน! </td>
</tr>
<tr id = "divc">
<td bgcolor = "#9966ff"> </td>
</tr>
</table>
</body>
</html>
ฉันหวังว่าบทความนี้จะเป็นประโยชน์กับการเขียนโปรแกรม JavaScript ของทุกคน