Hi all,
I wanted to evaluate this script in jquery:
var name = "Brian";
var txt = "This is your {name}";
Anyone can help me? I'm very noob for this one.
Thanks
Hi all,
I wanted to evaluate this script in jquery:
var name = "Brian";
var txt = "This is your {name}";
Anyone can help me? I'm very noob for this one.
Thanks
You could concatenate:
var name = "Brian";
var txt = "This is your " + name;
or you could replace your placeholder:
var name = "Brian";
var txt = "This is your {name}";
txt = txt.replace('{name}', name);
If you want more sophisticated string formatting I recommend you to give a look to the StringFormat jQuery plugin