-1

I looked for a while to find a solution to this but I guess either I am not wording it right or maybe this solution isn't common.

Please see my below example:

    var someScript = '<scr'+'ipt type="text/javascript" src="" tag="vendorId" 
async="async"></scr'+'ipt>';

In the tag attribute, 'vendorId' is actually a variable that has a value. How can I render the value of the variable rather than the key?

KPO
  • 890
  • 2
  • 20
  • 40
  • question is unclear. Render the value in script line or render the value through jquery you added as tag? –  Aug 22 '14 at 01:39

1 Answers1

2

You can make use of string concatenation over here

You can do something like this:

var vendorId = '';//Need to pass in your value over here 
var someScript = '<scr'+'ipt type="text/javascript" src="" tag="'+vendorId+
  '" async="async"></scr'+'ipt>';
Igor
  • 15,833
  • 1
  • 27
  • 32
V31
  • 7,626
  • 3
  • 26
  • 44