Replacing tab characters in JavaScript

前端 未结 3 1225
说谎
说谎 2020-12-08 14:58

Please consider the following HTML

 element:

This is some  
example code which    
     contains tabs         


        
3条回答
  •  囚心锁ツ
    2020-12-08 15:59

    Try this:

    var tab = RegExp("\\t", "g");
    document.getElementById("text").value =
    document.getElementById("text").value.replace(tab,'    ');
    

提交回复
热议问题