Home > Web Front-end > JS Tutorial > How to get all the data of a row of TD in the table after JS selects the checkbox_javascript skills

How to get all the data of a row of TD in the table after JS selects the checkbox_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 15:51:49
Original
1894 people have browsed it

The example in this article describes the method of obtaining all the data of a row of TD in the table after JS selects the checkbox. Share it with everyone for your reference. The specific implementation method is as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<html> 
<head> 
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
 <title>Untitled</title> 
 <script> 
  function test(o) { 
   if (!o.checked) { 
    return; 
   } 
   var tr = o.parentNode.parentNode; 
   var tds = tr.cells; 
   var str = "you click "; 
   for(var i = 0;i < tds.length;i++){ 
    if (i < 3) { 
     str = str + tds[i].innerHTML + "--"; 
    } 
   } 
   alert(str); 
  } 
 </script> 
</head> 
<body> 
<table width="60%" cellspacing="0" cellpadding="0" align="left" border="1" bordercolordark="#ffffff" bordercolorlight="#B3B5B4" > 
 <tbody id="tabstore1"> 
  <tr> 
   <td>b1</td> 
   <td>b2</td> 
   <td>b3</td> 
   <td><input type="checkbox" onclick="test(this);"/></td> 
  </tr> 
  <tr> 
   <td>c1</td> 
   <td>c2</td> 
   <td>c3</td> 
   <td><input type="checkbox" onclick="test(this);"/></td> 
  </tr> 
 </tbody> 
</table> 
</body> 
</html>

Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Where is js written?
From 1970-01-01 08:00:00
0
0
0
js file code not found
From 1970-01-01 08:00:00
0
0
0
js addClass not working
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template