tags:

views:

692

answers:

2

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

+2  A: 

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

CMS
A: 

var name = "Brian";
var txt = "This is your "+name ;

Srikanth