Jump to content

Images with javascripts style thing..


reportingsjr
 Share

Recommended Posts

I know this may sound stupid and I dont feel like googling atm, but how woujld you use the css style thing in javascript to define a url of an image? Heres what I tried, but im guessing you still have to use the url() declaration since it is still css. div.style.background-image = 'http://domain.com/image.png';.So to you javascript gurus what do I do to get this to work? :)

Link to comment
Share on other sites

div.style.backgroundImage="url('image url')";Should work. I think :)Or you could just do:div.background="url of image"Tell me if neither works. I'm slightly sleepy right now. :)

Link to comment
Share on other sites

  • 2 weeks later...

I'm not entirely sure what you want... but I've got a suggestion, and I'm not sure if it will work.To define the Background COLOR or IMAGE in javascript <script> tag

\\This one will only work for background COLORSdocument.getElementById("divID").bgColor="#CCCCCC"\\I doubt that this next one will work, but you could try it.\\If it works, it will work for background IMAGESdocument.getElementById("divID").background="http://www.domain.com/image.png"

To define the Background image in CSS <style> tag

\\This SHOULD workdiv.style.backgroundImage.url()\\something like that

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...