Remove spaces from starting and from end of the string using JQuery.

Virendradugar
Posted by Virendradugar under jQuery category on | Views : 4997
Below code will show paragraph using JQuery. You can download the Jquery from http://docs.jquery.com/Downloading_jQuery


<script type="text/javascript" src="Script/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var str = " Virendra Dugar @ Dotnetfunda.com ";
str = jQuery.trim(str);
alert(str);
});
</script>


Jquery provides a in-built function called trim() which removes spaces from starting and from end of the string.
Output of this would be "Virendra Dugar @ Dotnetfunda.com ". Trim() function only removes spaces from starting and end of the string. If there are any space between middle of the statement that is ignored.

Visit my blog
http://jquerybyexample.blogspot.com/

Comments or Responses

Login to post response