이 기사에서는 Checkbox를 선택하기위한 전체 데이터 행을 얻는 JS 방법에 대해 설명합니다. 참조를 위해 공유하십시오. 특정 구현 방법은 다음과 같습니다.
코드 사본은 다음과 같습니다.
<html>
<헤드>
<meta http-equiv = "content-type"content = "text/html; charset = utf-8">
<title> js </title>
</head>
<script language = "javaScript">
함수 getTdText ()
{
var rows = document.getElementById ( "test_table"). 행;
var a = document.getElementsByName ( "r");
// var states = "";
var table = document.getElementById ( "test_table");
for (var i = 0; i <a.length; i ++)
{
if (a [i] .Checked) {
var row = a [i] .parentElement.parentElement.rowindex;
// states += 행 [행] .Cells [1] .innerHtml +";";
경고 (a [i] .Value);
경고 (행 [행] .Cells [1] .innerHtml);
}
}
}
</스크립트>
<body>
<table id = "test_table">
<tr> <td> <input type = "checkbox"name = "r"value = "1"> </td> <td> a </td> </tr>
<tr> <td> <입력 유형 = "checkbox"name = "r"value = "2"> </td> <td> b </td> </tr>
<tr> <td> <입력 유형 = "checkbox"name = "r"value = "3"> </td> <td> c </td> </tr>
<tr> <td> <입력 유형 = "checkbox"name = "r"value = "4"> </td> <td> d </td> </tr>
<tr> <td> <입력 유형 = "checkbox"name = "r"value = "5"> </td> <td> e </td> </tr>
<tr> <td> <입력 유형 = "checkbox"name = "r"value = "6"> </td> <td> f </td> </tr>
</테이블>
<input type = "button"onclick = "getTdText ()"value = "button">
</body>
</html>
이 기사가 모든 사람의 JavaScript 프로그래밍에 도움이되기를 바랍니다.