Home  >  Article  >  Web Front-end  >  JS removal of leading and trailing spaces (IE9 personal test)_javascript skills

JS removal of leading and trailing spaces (IE9 personal test)_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:28:48882browse
Copy code The code is as follows:



< ;title> IE9 Personal Test JS Various Space Removal Collection

<script> <br>function clearSpace(inputO){ <br>var valueText=inputO.value ; <br>//Remove leading and trailing spaces<br>var text1=valueText.replace( /^s /, "" ).replace( /s $/, "" ); <br>//Remove all spaces<br> var text2=valueText.replace(/[ ]/g,""); <br>//Remove the leading space<br>var text3=valueText.replace( /^s /, "" ); <br>//Remove it Post space<br>var text4=valueText.replace( /s $/, "" ); <br>alert("==" text1 "=="); <br>alert("==" text2 "== "); <br>alert("==" text3 "=="); <br>alert("==" text4 "=="); <br>} <br></script>





Simple and practical, IE9 personal test, all kinds of spaces can be removed! ~~
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