FlyingCat
FlyingCat

Reputation: 14250

How to set dynamic image path

I want to use dynamic variable for my image.

I have something like

var img = 'test'

var path = "<img src="'../images/' + img + '_default_path.png'"></img>";

but it gave me errors. I know it might be just the quote issue but I am not sure where went wrong. Can someone please help me on this?

Thanks a lot!

Upvotes: 0

Views: 2795

Answers (1)

Pete
Pete

Reputation: 58432

Try this:

var path = '<img src="../images/' + img + '_default_path.png" />';

Upvotes: 5

Related Questions