0

I am trying to set the image of a div. This code doesn't work:

    var myUrl=profilePhotoFile.url()
    var div=document.getElementById("vignette")
    console.log(div)
    div.style.content="url(profilePhotoFile.url()) no-repeat";

profilePhotoFile.url() returns a string, by the way

2 Answers 2

1

I guess you are trying to set image as a background .?

if yes

//var myUrl=profilePhotoFile.url()
//setting temp image URL
var myUrl = "https://www.google.co.in/images/srpr/logo11w.png";
var div = document.getElementById("vignette");
div.style.backgroundImage="url("+myUrl+")";
div.style.backgroundRepeat="repeat-y";

jsfiddle URL: http://jsfiddle.net/naveenkumarpg/o0c6LLo0/1/

if yo want to set image in side vignette container

//var myUrl=profilePhotoFile.url()
//setting temp image URL
var myUrl = "https://www.google.co.in/images/srpr/logo11w.png";
var div = document.getElementById("vignette");
div.innerHTML="<img src="+myUrl+">";

jsfiddle : http://jsfiddle.net/naveenkumarpg/o0c6LLo0/2/

Sign up to request clarification or add additional context in comments.

Comments

0

You likely mean

div.style.content="url("+profilePhotoFile.url()+") no-repeat";

However I do not think the no-repeat is used for content, normally it is for background-image

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.