Combining JQuery variable + template variable
I am trying to pre-pend a template variable to a JS variable. I currently have:
var filename = some_variable
$('#file_extension_input').val(filename);
And it is populating the following form field:
<input type="input" name="key" value="" id="file_extension_input">
With a resulting outcome would be, for example, value="test.jpg"
How would I pre-pend a template variable to the .val
so it would be something like this:
var filename = some_variable
$('#file_extension_input').val( {{username}} + filename);
And the resulting oucome would be, for example,开发者_如何学运维 value="johnsmith/test.jpg"
. Thank you.
var prefix = '{{username|escapejs}}';
var filename = some_variable;
$('#file_extension_input').val(prefix + filename);
精彩评论