jQuery multiple character replace -
I have a very simple question. Unfortunately, I could not find an answer.
I have just created 2 simple input functions
Input 1: & lt; Br / & gt; & Lt; Input type = "text" id = "i1" name = "i1" /> Input 2: & lt; Br / & gt; & Lt; Input type = "text" id = "i2" name = "i2" /> When changing the input 1, I want to reveal the result in Input 2. Apart from this, I should change some characters and I want to make the letter less case (in order to use it) a url). So I have created the following jQuery code:
$ ("# i1"). Key (function () {var ptitle = $ ("# I1"). Val (); $ ("# 2"). Val (ptitle.replace ("", "-"). ToLowerCase ());}) ;
This works fine, except that when I type a string that has the same character several times to replace it. Then it only changes for the first time. For example: When I write in Input 1: 'About this company' the result will be in Input 2: 'About this company' should be: 'About-this-company' Does anyone know What's wrong with my jQuery code?
something like this:
$ ("# i1") key (Function () {var ptitle = $ (this) .val (); $ ("# i2"). Val (ptitle.replace (/ \ s / g, "-"). ToLowerCase ());});
Comments
Post a Comment