Home > Article > Web Front-end > js/jquery remove spaces, carriage returns, line feeds sample code_jquery
Jquery:
$("#accuracy").val($("#accuracy").val().replace(/ /g,"" ));//Remove spaces
.replace(/ /g,"") //Remove spaces method
$("#content").val($("#content").val().replace (/[ ]/g,"")); //Remove spaces
.replace(/[ ]/g,"")//Remove spaces
$("#content").val($("#content").val(). replace(/[rn]/g,""));//Remove carriage return and line feed
.replace(/[rn]/g,"")//Remove carriage return and line feed
.replace(/-/g, '') //Remove the "-" sign
js:
var testStr="sssss
vvvvv";
var resultStr=testStr.replace(/ /g,"");//Remove spaces
resultStr=testStr.replace(/[ ]/g,""); //Remove spaces
resultStr=testStr.replace(/[rn]/g,""));//Remove carriage return and line feed