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

The Archive Base Latest Questions

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

The code in the first Code Block is the source code. After the source

  • 0

The code in the first Code Block is the source code. After the source code is running. The code will be changed (See the 2nd Code Block).

I want the class(i.e. ‘even’ and ‘odd’) of tag is only displayed in the ‘table1’. However, currently a nest table (i.e. ‘table2’) also has ‘even’ and ‘odd’ class of each tag.

Can anyone help me out? Thanks in advance.

———–First Code Block————–

<head>
<script type="text/javascript">
            $(document).ready(function(){
                $("#table1 tr:odd").addClass("odd");
                $("#table1 tr:not(.odd)").addClass("even");  
            });
</script>
</head>

<body>

<table id="table1">
    <tr>
        <td>AAA</td>
        <td>CCC</td>
    </tr>
    <tr>
        <td>BBB</td>
        <td>DDD</td>
    </tr>
    <tr>
        <td>
            <table id="table2">
                   <tr></tr>
                   <tr></tr>
            <table>
        </td>
    </tr>

</table>
</body>

———–2nd Code Block—————

<table id="table1">
    <tr class="even">
        <td>AAA</td>
        <td>CCC</td>
    </tr>
    <tr class="odd">
        <td>BBB</td>
        <td>DDD</td>
    </tr>
    <tr class="even">
        <td>
            <table id="table2">
                   <tr class="even"></tr>
                   <tr class="odd"></tr>
            <table>
        </td>
    </tr>

</table>
  • 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-23T16:33:11+00:00Added an answer on May 23, 2026 at 4:33 pm

    All of the posted answer are almost right..

    $(document).ready(function(){
        $("#table1 > tbody > tr:odd").addClass("odd");
        $("#table1 > tbody > tr:not(.odd)").addClass("even");  
    });
    

    Many browsers automatically add a tbody to your table even if you don’t add one yourself. So #table1 > tr will not match because tr is not a direct child of table. Your best bet is to use the above and explicitly add a tbody for those browsers that don’t do it for you.

     <table id="table1">
          <tbody>
            <tr class="even">
                <td>AAA</td>
                <td>CCC</td>
            </tr>
            <tr class="odd">
                <td>BBB</td>
                <td>DDD</td>
            </tr>
            <tr class="even">
                <td>
                    <table id="table2">
                       <tbody>
                           <tr class="even"></tr>
                           <tr class="odd"></tr>
                       </tbody>
                    <table>
                </td>
            </tr>
          <tbody>
    
    </table>
    

    http://jsfiddle.net/5ETAD/1/

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

Sidebar

Related Questions

in the code below at first if statements block (there will be more than
I often refactor code first by creating an inner class inside the class I'm
I got the problem that the if-statement doesn't work. After the first code line
This code is copy from http://code.google.com/p/closure-library/source/browse/trunk/closure/bin/build/source.py The Source class's __str __method referred self._path Is
Code first: '''this is main structure of my program''' from twisted.web import http from
I have an AXIS2/JAX-WS web service using a code first implementation (yes I know,
I'm using the STL map data structure, and at the moment my code first
i am stuck at scope resolution in python. let me explain a code first:
here's the main code at first I thought is was the message box but
Which one below is correct? First code has no quotes in the $_GET array

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.