Using trim() function in jQuery

jQuery also have trim function like javascript trim, which removes spaces from starting and from end of the string. See below code.

<script type="text/javascript">
$(document).ready(function(){
    var str = "    I Love jQuery    ";
    str = jQuery.trim(str);
    alert(str);
});
</script>

Output of this would be "I Love jQuery". 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.

Feel free to contact me for any help related to jQuery, I will gladly help you.



Responsive Menu
Add more content here...