javascript - hide button in a row on certain value of a column -


i have autogenerated table tasks , status. each row has button restart task.

i want hide restart button if the value of task isn't equal "error". in other words: tasks status==error should have visible restart button

here fiddle link: https://jsfiddle.net/hwqt7c3a/5/

i have tried:

window.onload = function () {             $(function () {                 $('table tr').each(function () {                     var cells = this.getelementsbytagname("td");                     if (cells[2].innertext !== 'error') {                         $(this).find('button').style.visibility = 'hidden';                     }                 });             });         } 

but reason cells empty.

i have updated fiddle , here working fiddle

$(function() {                             //document ready event   $('table tr').each(function() {          //loop tr's     var cell = $(this).find('td:eq(2)');   //find 3rd td cell     if (cell.text() !== 'error') {         //check if text "error"        $(this).find('button').hide();       //if try find button of tr , hide               }   }); }); 

do not mix javascript , jquery syntax,

also don't need both these lines

window.onload = function () { // javascript way of handling document ready             $(function () {   // jquery way of handling document ready. 

use either one, since using jquery library better use

$(function () { 

so dont mix syntaxes..


if want td take button space in ui still hidden have use

$(this).find('button').css("visibility","none") 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -