Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 17:28:48
Original
882 people have browsed it
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! ~~
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!