Monday, February 26, 2024
 Popular · Latest · Hot · Upcoming
rated 0 times [  22] [ 3]  / answers: 1 / hits: 22270  / 11 Years ago, sat, september 28, 2013, 12:00:00

I have a variable that I can display on the page by using the following

I can copy the result to the browser and it displays the file I require.

What I want to do is to take that variable and use it to specify the src of my background image

`<p style=background-image: url(**image**);>`

I know that this is probably simple to you guys, but I have spent the whole day and am losing a lot of hair over this one. Thanks for your time....

More From » variables


If the element is selectable :

<p id=paragraph>Some text</p>

You can change the style with javascript:

document.getElementById('paragraph').style.background = 'url('+image+')';

if you're creating the paragraph you can do:

var p = document.createElement('p'); = 'url('+image+')';

[#75370] Thursday, September 26, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 114
Total Questions: 95
Total Answers: 110

Location: Bonaire
Member since Sat, May 27, 2023
10 Months ago