www.webdeveloper.com
Results 1 to 4 of 4

Thread: Assigning to Element.style.backgroundImage

  1. #1
    Join Date
    May 2011
    Posts
    4

    Assigning to Element.style.backgroundImage

    I can not Seem top work out how to assign to make the following work:

    document.getElementById("header-3").style.backgroundImage = "url(parmsarray[position])";

    Or the following : document.getElementById("header-3").style.backgroundImage = "url(tmp);

    where tmp and document.getElementById("header-3").style.backgroundImage = "parmsarray[position] are variables.

    your help you d be gratefully appreciated

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Presuming that parmsarray is a variable (an array) previously defined:
    Code:
    document.getElementById("header-3").style.backgroundImage = "url("+parmsarray[position]+")";

  3. #3
    Join Date
    May 2011
    Posts
    4
    Thanks thats just what i needed i busting a gut for over two hours to find a solution.

    what is that construct called doing the +varible+ thing ? passing by ...

  4. #4
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles