7
How I replace a string in Javascript?
I’m taking the name of the page.
var str = window.location.pathname;
The name of the url is "/checkout/9/finalizacao"
I want to change to "/checkout/"
In the first 10 characters.
I know there is the sub string method, but I don’t know how to use it.
You don’t have to put in complicated code, just the function I use to get the first 10 characters and how to implement it. ('Cause I’m gonna use it on an if later)
if (pageName == "/carrinho/index" || str == "/checkout/"){
}
It worked, I used: var str = window.location.pathname; str = str.substring(0,10);
– Felipe Jorge
That’s right, you get the value on
str
how do you intend :)– CesarMiguel