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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:32:28+00:00 2026-06-05T22:32:28+00:00

I am using query index() method to get the index of an element relative

  • 0

I am using query index() method to get the index of an element relative to its parent.

Here are two codes :
Code1

<div id="check1">
    <p>  
        <span> 
            <b> Bold Line 1 </b>
            <b> This is line2 </b>
        </span>
    </p>
    <p> Should have index 1 </p>
</div>

Code2

<div id="check2">
    <p>  
        <span> 
            <b> Bold Line 1 </b>
            **<p> This is line2 </p>**   //replaced <b> with <p>
        </span>
    </p>
    <p> Should have index 1 </p>
</div>

In code2, I just replaced the 2nd bold name with p tag name.

Area of doubt is answer varies in both these cases.
Answers are:

Case1: index comes 1
Case2: index comes 3

Please check this out. “Click on Should have index 1”
http://jsfiddle.net/blunderboy/U73VV/

And moreover, when I click on “This is line2” on both checks, their parents are coming different. In check1, parent is span and in check2 parent is div.

Please let me know what difference I am making just by changing the tagName. Their relative position w.r.t their parent is still same.

  • 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-05T22:32:30+00:00Added an answer on June 5, 2026 at 10:32 pm

    You can’t place <p/> tags inside <p/> tags. You are ending up with the following markup:

    <div id="check2">
      <p>  
        <span> 
          <b> Bold Line 1 </b>
        </span>
      </p>
      <p> This is line2 </p>
      <p> Should have index 1 </p>
    </div>
    

    You might want to replace <b/> with a <span/> instead to keep the layout.

    Or, if what you want is to change the bold attribute of the tags, you can use CSS for it. This won’t need you to mess around with the layout.

    .bold { text-weight: bold; }
    

    Toggling the bold class:

    <div id="check1">
      <p>  
        <span> 
          <!-- This is bold -->
          <span class="bold"> Bold Line 1 </span>
          <!-- This one is not bold -->
          <span> This is line2 </span>
        </span>
    </p>
    <p> Should have index 1 </p>
    

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

Sidebar

Related Questions

I am using solr search engine to query an index for classifieds that match
Instead using the google search appliance crawler for index content, im using a query
I'm using this SQL query to create an index: $query = CREATE INDEX id_index2
Is there is any way to get the select Random Records using query from
When I add event handler to a some elements using query: $('div').mouseover(function () {
I have not clearly issue during query using two criterials like Id and Other.
I have a corpus of token-index based documents which offers a query method. The
I am using WCF REST service (GET method) to retrieve my EF4 POCOs. The
I have two tables 'p_tuts' and 'h_tuts'. I'm using a method to display all
Why does the java.util.Set interface lack get(int Index) , or any similar get() method?

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.