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

  • Home
  • SEARCH
  • 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 6054773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:11:26+00:00 2026-05-23T08:11:26+00:00

I am writing a web page which updates a list using jQuery when something

  • 0

I am writing a web page which updates a list using jQuery when something is selected. Below the list is a button. The update works fine in Firefox and Chrome, but in IE, a bit of space is added between the list and the button every time it updates. Following is a stripped-down example that does the same thing:

<html>
    <head>
        <style type="text/css">
            #list {
                padding: 10;
            }
        </style>

        <script type="text/javascript" src="jquery.js"></script>
    </head>

    <body>
        <div id="test">
            <ul>
                <!-- List -->
                <li>
                    <div id="list">
                        <ul>
                            <li>before 1</li>
                            <li>before 2</li>
                        </ul>
                    </div>
                </li>

                <!-- Button -->
                <li>
                    <div>
                        <button id="button" onClick="reload();">button</button>
                    </div>
                </li>
            </ul>
        </div>
    </body>

    <script type="text/javascript">
    function reload() {
        var html = 
            "<ul>" +
                "<li>after 1</li>" +
                "<li>after 2</li>" +
            "</ul>";

        $("div#list").html(html);
    }
    </script>
</html>

Click the button. In Firefox and Chrome, it stays put. In IE (9), it shifts down a bit (a bit meaning about 10 or 20 pixels. Easily noticeable to the human eye, that is) every time I click it. Can anyone tell me what is causing this?
Thanks.

  • 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-23T08:11:27+00:00Added an answer on May 23, 2026 at 8:11 am

    Update
    Seems like the problem is related to IE padding calculating rather than your code, since the same happens using js .innerHtml() directly.

    I would then suggest removing the padding and adding margins to the ul, since it affect the element you are removing maybe also the margins will be removed this time.

    #list {
        padding: 0;
    }
    #list ul {
        margin:10;
    }
    

    http://jsfiddle.net/qEphF/6/


    According to jQuery docs

    This method uses the browser’s
    innerHTML property. Some browsers may
    not generate a DOM that exactly
    replicates the HTML source provided.

    Maybe you should try a different approach. For example

    $("div#list").empty().append($(html)); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been toying with writing a web app using jquery mobile which makes use
I'm writing a web page that will detect which college campus a user is
Say you're writing a web page for fruit vendors using Spring MVC's SimpleFormController ,
I'm making a web page using CGI scripting which has a form users need
I'm writing a web page in ASP.NET. I have some JavaScript code, and I
When writing a query for paging on a web page what is the least
I'm writing part of a web page that allows a user to build a
I am writing a Java applet and embedding it in a web page. It
I am writing a bookmarklet in which I want to use the jquery forms
I often found some URL which looks like the following: www.something.com/some_page/#someword After writing this

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.