jayt.dev
jayt.dev

Reputation: 1015

Passing a js var into jquery action as attribute

var temp="path.png"

How can I pass temp var into the jquery function as shown below

$('#mapfoto').prepend('<img id="theImg"  src="http://path.gr/"+temp />')

Upvotes: 0

Views: 65

Answers (2)

user1850421
user1850421

Reputation:

$('#mapfoto').prepend('<img id="theImg"  src="http://path.gr/' + temp + '" />');

Upvotes: 1

VisioN
VisioN

Reputation: 145408

Use correct quotes placement in string concatenation:

$('#mapfoto').prepend('<img id="theImg" src="http://path.gr/' + temp + '" />');

Upvotes: 1

Related Questions