A Pen by Jeff Christian

Thumbnail
This awesome code was written by 15chrjef, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright 15chrjef ©
  • HTML
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>A Pen by  Jeff Christian</title>
  
  
  
  
  
</head>

<body>

  <input type='text' id='search'>
<table>
  <tr>
    <th>
      Name
    </th>
  </tr>
  <tr>
    <td>Jeff</td>
  </tr>
  <tr>
    <td>Goerge</td>
  </tr>
  <tr>
    <td>Lt. Dan</td>
  </tr>
</table>
  
  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/15chrjef/a-pen-by-jeff-christian-zZmxgR */
var searchTxt = document.getElementById('search')

console.log(searchTxt)
const filterTable = () => {
console.log('filtering')
  var tbl = document.getElementsByTagName('table')
  var tBodies =tbl[0].tBodies[0].children
  var tBodyArr= Array.prototype.slice.call( tBodies, 1 )
  console.log(tBodyArr)
  tBodyArr = tBodyArr.forEach( tBody => {
    var txt = tBody.innerText;
    var flag = true;
    tBody.style.display = txt === searchTxt ? 'text-data' : 'none';
  })
}

console.log(searchTxt)
searchTxt.addEventListener('readystatechange', filterTable)

Comments