Answers for "how to remove all spaces from a string in jquery"

1

jquery replace all spaces in string

<body>
  Title : <input type="text" id="title"><br/>
  Keyword : <input type="text" id="keyword">
</body>
<script>
  $('#title').keyup(function() {
    var replaceSpace = $(this).val(); 

    // regular expression / /g ()
    // The flag g means global. It causes all matches to be replaced
    var result = replaceSpace.replace(/ /g, ";");

    $("#keyword").val(result);

  });
</script>
Posted by: Guest on July-09-2021

Code answers related to "how to remove all spaces from a string in jquery"

Browse Popular Code Answers by Language