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 7686335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:27:22+00:00 2026-05-31T19:27:22+00:00

Using jQuery in IE8, I’m creating a div with a class (ex. <div class=className></div>

  • 0

Using jQuery in IE8, I’m creating a div with a class (ex. <div class="className"></div>). This class has several CSS styles on it, including background, margin, and border. When debugging the javascript in IE9 (running as IE8), and inspecting the element, all of the currentStyles have the default values, instead of the values from the CSS. So, when I try to get the margin, it comes back as being set to auto even though the CSS puts it at 10px.

The script has no errors and it does work as expected in Firefox, Chrome, and IE9. Any thoughts?

  • 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-05-31T19:27:23+00:00Added an answer on May 31, 2026 at 7:27 pm

    With some help from the comments above (under the original question), I found out that the div was not actually in the DOM at the time I was trying to get its CSS properties, which is why I was seeing only the default CSS for the element. Granted, IE9, Firefox, and Chrome all handled this fine, but it does make sense that the element would need to be in the DOM first.

    As a workaround, I append() a hidden input to the DOM, with the same classes as the div. I can then get the CSS properties/values that I need and then remove the input. While not ideal, this is an acceptable solution for the time being.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When using jQuery to insert HTML into a div in IE8, IE8 strips the
Using jQuery 1.4.2 (IE8 in compatibility mode) Given the following structure: <div id='something'>something</div> <div
I'm using jQuery UI, and have built a toolbar (a div element), with button
I am creating a modal window using jquery. I am having an issue with
I'm making a sort elements web game using jQuery, HTML & CSS. While everything
Here's a dead-simple webpage that leaks memory in IE8 using jQuery (I detect memory
I encountered an issue using jQuery's .delegate() method on IE8 when removing the elements
I run into a problem with jQuery UI - Autocomplete and IE8. I'm using
Summary I am using jQuery to clone a div (boxCollection) containing groups (groupBox) each
I'm conditionally loading a script if the browser is IE8. I'm using jquery's .getScript

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.