1
I don’t know if it’s the split you use in jquery, but I’m not succeeding. In my code I get the value of ID that comes dynamically, I want to divide the ID in two. A part up to character 16 and then the rest.. how can I do this?
1
I don’t know if it’s the split you use in jquery, but I’m not succeeding. In my code I get the value of ID that comes dynamically, I want to divide the ID in two. A part up to character 16 and then the rest.. how can I do this?
1
The following code speaks for itself.
It takes a string value, its dynamic id and distributes between 2 variables(String):
var id = "suaIDgeradaDinamicamente";
var primeiraParteID = id.substring(0,16);
var segundaParteID = id.substring(16);
console.log("ID :"+id+" - "+id.length);
console.log("Primeira parte da id 0 até 16 caracteres :"+primeiraParteID);
console.log("Segunda parte da id :"+segundaParteID);
Thank you so much it worked so I was really in need, one more learning, I was using the split and I couldn’t, now I know what I use.
Great, I avoided using the split, because it’s not very complex and the substring because it’s native has a better performance.
Browser other questions tagged javascript jquery
You are not signed in. Login or sign up in order to post.
Please show your code.
– Stéfano
The function you seek is
substr
, but as already commented, it will be better if you [Edit] the question and add your code to know exactly what you need and how to solve.– Woss
@Taynara Jaegger add the code to your question please.
– Leandro