Javascript custom function with a check inside for loop -
i'm overcomplicating things...and it's difficult explain i'll show code here:
for (var = 0; < x.length; i++) {     (function(i) {         if (x[i].classname === 'ru') {             x[i].style.display = 'none';             if (x[i].previoussibling.tagname === 'br' && x[i].previoussibling.style.display != 'none') {                 x[i].previoussibling.style.display = 'none';             }         }     })(i); }   that works fine create function inside loop check each x[i].previoussibling if of type 'br'.  need declare function loop until reaches element not 'br' tag.  tried:
for (var = 0; < x.length; i++) {     (function(i) {         if (x[i].classname === 'ru') {             x[i].style.display = 'none';             var check = true;             var = '';             function foo() {                 while (check) {                     if (x[i].previoussibling.tagname === 'br' && x[i].previoussibling.style.display != 'none') {                         x[i].previoussibling.style.display = 'none';                         = x[i].previoussibling;                     }else                         check = false;                     foo();                 }             }         }     })(i); }   and did nothing...i don't think got inside foo function.  suggestions?
here's worked after tweaking , getting rid of unnecessary variables:
for (var = 0; < x.length; i++) {     (function(i) {         if (x[i].classname === 'ru') {             x[i].style.display = 'none';             var = x[i];             foo();             function foo() {                 if (a.previoussibling && a.previoussibling.tagname === 'br' && x[i].previoussibling.style.display != 'none') {                     x[i].previoussibling.style.display = 'none';                     = a.previoussibling;                     foo();                 }             }         }     })(i); }      
Comments
Post a Comment