Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9010851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:34:22+00:00 2026-06-16T02:34:22+00:00

I have a simple create div script but the background image is not being

  • 0

I have a simple create div script but the background image is not being created which is bugging me.

I tried a few ways but none of them work:

var d = document.createElement('div');
d.id = 'content';
d.className = 'inner';
d.background = "url=('images/h.png')";
document.getElementById('menu').appendChild(d);

I also tried these alternative methods:

d.style.background = "url=('images/h.png')"; 
d.backgroundImage = "url=('images/h.png')";
d.style.backgroundImage = "url=('images/h.png')";

All 3 don’t work but the div does load and the height is deffinately not 0px as there is a paragraph of text in there… the CSS for the div is:

.inner{
    text-align:center;
    background-repeat: no-repeat;
    background-position: top center;
    width:100%;
    padding-top:30px;
    min-height:300px;

}

According to my Chrome debugging tools, the image does not load in the resources, its not even requested to load. If i i had the wrong url I would get resource not found, so I’m wondering if there is a specific way to write it in JS to get this work ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:34:24+00:00Added an answer on June 16, 2026 at 2:34 am

    Why do you have an equals sign in there? Take it out and your code should work:

    d.style.backgroundImage = "url('images/h.png')";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to create a simple dropdown menu with div but i have this
i tried to create a simple css background-image transition usind the jquery fadeIn fadeOut
I have created a simple layout using the HTML div tag. I would like
I have simple table creating script in Postgres 9.1. I need it to create
How to manually create Friendly URLs? (PHP) So I have created simple php file
i have a script that creates divs with some background image then moves them,
I have created a simple dropdown menu using CSS and want to create a
I have a bit of simple created with XAJAX, which replaces the innner HTML
I have created a simple vf page and placed and small jQuery script in
I currently have a simple <div contenteditable=true> working, but, here's my problem. Currently, the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.