Using sprintf in jQuery
javascript, jquery
Solution
If it's really as simple as you've described, just use `String#replace` with a regular expression (so you can use the `g` flag to make the replacement happen throughout the string):
$('.data').html(html.replace(/%s/g, 'TEST'));
Problem
How can I use sprintf in jQuery? I'm trying to add an `id` to a chunk of HTML that is returned from a script So: ``` success: function(html){ $('.data').html($.sprintf(html,'TEST')); }, ``` The HTML that is returned is a large chunk of HTML where i've added a `%s` for sprintf to do it's replacement. Eg: `'<div>Welcome to Blah</div><div>You userId is %s</div>'`