Saturday, December 14, 2013

Drop rows out of a HTML table in JavaScript with deleteRow!

$scope.removeAsset = function(asset) {
   var assettable = document.getElementById('assettable');
   var rows = assettable.getElementsByTagName('tr');
   for(i=0; i < rows.length; i++) {
      var cells = rows[i].getElementsByTagName('td');
      if (cells[0]) {
         var link = cells[0].innerHTML;
         if(cells[0]) {
            if(cells[0].innerHTML) {
               if (cells[0].innerHTML.indexOf("/" + asset.pKey + "/") > -1) {
                  assettable.deleteRow(i);
               }
            }
         }
      }
   }
}

No comments:

Post a Comment