$(document).ready(function() { $('#searchform input').keyup(trimkeyup); }); function trimkeyup(e) { lucene_objInput = $(this); if(e.keyCod"/> $(document).ready(function() { $('#searchform input').keyup(trimkeyup); }); function trimkeyup(e) { lucene_objInput = $(this); if(e.keyCod">

Home >Web Front-end >JS Tutorial >How to remove the spaces before and after the input box in jquery?

How to remove the spaces before and after the input box in jquery?

零下一度
零下一度Original
2017-06-26 14:46:562631browse

1.

2.

<script type="text/javascript">$(document).ready(function() {
     $('#searchform input').keyup(trimkeyup);
 }); function trimkeyup(e) {
    lucene_objInput = $(this);     if(e.keyCode != 38 && e.keyCode != 40 && e.keyCode != 13) {       var im = $.trim(lucene_objInput.val());
       lucene_objInput.val(im); 
    }
}  
</script>

 

The above is the detailed content of How to remove the spaces before and after the input box in jquery?. For more information, please follow other related articles on the PHP Chinese website!

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