Home  >  Article  >  Web Front-end  >  js/jquery remove spaces, carriage returns, line feeds sample code_jquery

js/jquery remove spaces, carriage returns, line feeds sample code_jquery

WBOY
WBOYOriginal
2016-05-16 17:17:341334browse

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn