Technical interview questions for software engineers — languages, databases, web, cloud, DevOps, and fundamentals. Browse all topics.

  • PHP Interview Questions

  • OOP Interview Questions

  • jQuery Interview Questions

  • MySQL Interview Questions

  • JavaScript Interview Questions

  • HR Interview Questions

  • HTML Interview Questions

  • C/C++ Interview Questions

  • Showing posts with label js trim whitespace. Show all posts
    Showing posts with label js trim whitespace. Show all posts

    jquery trim spaces - jQuery $.trim method

    jquery trim spaces - jQuery $.trim method

    In this tutorial, I will explain how to removes the two whitespaces at the start and at the end of the string.
    Removes the two whitespaces at the start and at the end of the string.
    <html>
    <title>jquery trim spaces</title>
    <head>
      <script src="http://code.jquery.com/jquery-latest.js"></script>
        <script>
      $(document).ready(function(){
        
        $("span").click(function () {
          var str = "     jquery trim spaces     ";
          str1 = jQuery.trim(str);
          alert(str1);
        str2 = $.trim(str);//using the jQuery $.trim method
          alert(str2);
         });
      });
      </script>
    </head>
    <body>
      <span>jquery trim spaces</span>
    </body>
    </html>


    I hope this tutorial will help you to remove whitespaces at the start and at the end of the string.


    Bookmark and Share

    JQuery-Remove all spaces from string using javascript/JQuery/Regular expressions.

    Remove all spaces from string using javascript/JQuery/Regular expressions.

    In this tutorial, I will explain how to remove all spaces in a string using jquery,
    remove all occurences of a character from a string.
    I need to remove spaces in the string.I will use JQuery/Regular expressions/javascript to replace spaces from string.
    You can replace string with '_','-'....etc.
    Removing extra space from the string using javascript and Regular expression is very easy.
    <script type="text/javascript">
    function removeSpaces(str)
    {
    var s=str.replace(/\s/g, "");
    return s;
    }
    var new_str=removeSpaces('jquery remove space from string using javascript');
    </script>


    Bookmark and Share