javascript - Using sprintf in jQuery -


this question has answer here:

how can use sprintf in jquery?

i'm trying add id chunk of html returned script

so:

success: function(html){     $('.data').html($.sprintf(html,'test')); }, 

the html returned large chunk of html i've added %s sprintf it's replacement.

eg: '<div>welcome blah</div><div>you userid %s</div>'

if it's simple you've described, use string#replace regular expression (so can use g flag make replacement happen throughout string):

$('.data').html(html.replace(/%s/g, 'test')); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -