Remove the blank text node in html

Lower Dir a record notes

1  // blank html nodes removed with 
2      removeWhiteSpace ($ ( "content_toolbar.") GET (0. ));
 . 3      function removeWhiteSpace (elem) {
 . 4          the let || Document elem = EL, // must js subject 
. 5              CUR = el.firstChild,
 . 6              TEMP,
 . 7              REG = / \ S / ;
 . 8          the while ( null =! CUR) {
 . 9              TEMP = cur.nextSibling;
 10              IF ! (=== cur.nodeType && reg.test. 3 (CUR. the nodeValue)) { // node obtains the type is text and text blank 
11                 el.removeChild (CUR);
 12 is              } the else  IF (=== cur.nodeType. 1) { // if the recursive element 
13 is                  removeWhiteSpace (CUR);
 14              }
 15              CUR = TEMP;
 16          }
 . 17      }

 

Guess you like

Origin www.cnblogs.com/jiaqing521/p/11470261.html