1

I want to set any path of url to javascript file like :

$ image_path = "http://siteurl.com/inc/"

How to put into my code below:

css({"background":"url(image/bg.png) no-repeat scroll 0 0"}) 

I want to put inside url become url(image_path + image/bg.png) so my url css become http://siteurl.com/inc/image/bg.png

Thank you.

1 Answer 1

1

Concatenate it into the string, like so:

var image_path = "http://siteurl.com/inc/"

element.css("background" , "url(" + image_path + "image/bg.png) no-repeat scroll 0 0");
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.