Loans - Debt Consolidation - VeraciTek, Inc. - We Build Websites - Jobs search - Cheap Computer Parts

PDA

View Full Version : Backfound-image one, Should be simple but most needed!!


progfrog
May 14th 2008, 12:22 pm
hi guys,
i'm trying to change the backgroung-image of an object using a reguler js function that i wrote-

this is the code, but for some reason , it doesn't work:


tli.style.background="background-image: url('images/p.jpg') no-repeat";



tli is an object taht contain some <p>that i would like to change her background , but the code i wrote doesn't work- Can u help me??


thanx a lot
progfrog

crath
May 14th 2008, 5:08 pm
ok, in javascript, for doing css styles, for example, the "background-image" property, you must remove the hyphen and capitalize the second letter, like this, "backgroundImage". Next, javscript is an object oriented language, so you do objects and attributes. You need to make your code look like this.

tli.style.backgroundImage = "url('images/p.jpg') no-repeat";

See, it will set the "background-image" property of object "tli" to "url('img... bla bla bla"

:)

progfrog
May 15th 2008, 2:38 am
HI man, It doesn't work for me also.. can u try it your self and tell me what did u managed to do?

thanx again,
progfrog

crath
May 15th 2008, 5:26 am
did you first do var tli = document.getElementById("objectID");first?

progfrog
May 21st 2008, 3:39 am
yes, i did but is still doesn't work.. us there anything else that can make it work?

sorry for posting to u a week later..

crath
May 21st 2008, 12:19 pm
are you getting any errors or warnings?