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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:08:50+00:00 2026-06-03T17:08:50+00:00

my code is: <!DOCTYPE html> <html> <head> <title>Demo</title> <meta charset=utf-8/> <script src=https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js type=text/javascript></script> <script

  • 0

my code is:

<!DOCTYPE html>
<html>
<head>
    <title>Demo</title>
    <meta charset="utf-8"/>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function(){
            $("#table1 tr:gt(0) input[type='checkbox']").bind("click",function(){
                var id=  $(this).attr("id");
                var name=$(this).parent().next("td").text();

                if($(this).is(":checked")){
                    $("#table2").append("<tr id="+id+"><td>"+name+"</td></tr>");
                }
                else{
                    $("#table2 #"+id).remove();//why this not work in IE7?
                    //$("#"+id,$("#table2")).remove();//this work well
                }   
            })
        });
    </script>
</head>
<body>
    One:
    <table id="table1" border="1">
        <tbody>
            <tr><th></th><th>name</th></tr>
            <tr><td><input type="checkbox" id="Checkbox1" /></td><td>jim</td></tr>
            <tr><td><input type="checkbox" id="Checkbox2" /></td><td>tom</td></tr>
        </tbody>
    </table>
    <br/>
    Two:
    <table id="table2" border="1">
        <tbody>
            <tr><th>name</th></tr>
        </tbody>
    </table>
</body>
</html>

this code very simple,if table1 checkbox is checked,add the td to table2,otherwise remove td from table2,but $("#table2 #"+id).remove(); not work in ie7,i replace it to $("#"+id,$("#table2")).remove(); it can work well. who can tell me why?

  • 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-03T17:08:51+00:00Added an answer on June 3, 2026 at 5:08 pm

    The issue is specific to IE7 probably because it doesn’t support querySelectorAll, and so Sizzle is used.

    From the looks of it, you’re creating a new element that shares the same ID as an existing element. ID’s must be unique, so you can’t expect DOM selection to work when there are dupes.

    // Here you're getting the ID of the element that was clicked
    var id=  $(this).attr("id");
    var name=$(this).parent().next("td").text();
    
    if($(this).is(":checked")){
    
         // Here you're creating a new element with the same ID!!!
        $("#table2").append("<tr id="+id+"><td>"+name+"</td></tr>");
    }
    else{
        $("#table2 #"+id).remove();//why this not work in IE7?
        //$("#"+id,$("#table2")).remove();//this work well
    }   
    

    But you say this works:

    $("#"+id,$("#table2")).remove();
    

    That’s probably because Sizzle is doing this:

    var el = document.getElementById('table2');
    

    And then some thing like this:

    el.getElementsByTagName('*')
    

    Followed by a filter for the ID. That’s just a guess, but it isn’t that relevant anyway since the duplicate IDs must be resolved first.

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

Sidebar

Related Questions

my code is: <!DOCTYPE html> <html> <head> <title>Demo</title> <meta http-equiv=Content-Type content=text/html; charset=utf-8 /> <script
My code: <!DOCTYPE html> <html> <head> <title>Demo</title> <meta http-equiv=Content-Type content=text/html; charset=utf-8 /> <style type=text/css>
my code is: <!DOCTYPE html> <html> <head> <title>Demo</title> <meta http-equiv=Content-Type content=text/html; charset=utf-8 /> <style
I downloaded sizzle.js from https://github.com/jquery/sizzle my code is: <!DOCTYPE html> <html> <head> <title>Demo</title> <meta
This is my code taken from http://jqueryui.com/demos/draggable/ <!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8>
Sample code: <!DOCTYPE html> <html> <head> <title>test</title> <script language=javascript type=text/javascript> function init() { var
I'm having a problem with the following code snippet: <!DOCTYPE html> <html> <head> <title>Hangman</title>
I have this code: <!DOCTYPE html> <html> <head> <title>@ViewBag.Title</title> <link href=@Url.Content(~/Content/Site.css) rel=stylesheet type=text/css />
This is my code: <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd> <html> <head>
Here is my code: <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd> <html xmlns=http://www.w3.org/1999/xhtml>

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.