Home > Web Front-end > JS Tutorial > js tr controls the hiding and display of the tbody below_javascript skills

js tr controls the hiding and display of the tbody below_javascript skills

WBOY
Release: 2016-05-16 19:02:17
Original
1665 people have browsed it

The core code used is
function $(obj){
return document.getElementById(obj);
}
window.onload = function(){
var table = document.getElementById(" myTable");
//If a click occurs in the table area
table.onclick = function(e){
var e = window.event||e,target = e.srcElement||e .target;

//Get tr
while(target.tagName.toLowerCase() != "tr"){
target = target.parentNode;
}

var i = target.rowIndex;
//Click on a single row of Tr to control the hiding and display of tr 1

if(i%2 == 0){
var nrs = table .rows[i 1].parentNode.style;
nrs.display = nrs.display == "none"?"":"none";
}
}
}

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template