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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:18:34+00:00 2026-06-17T14:18:34+00:00

In my project. I am trying to check whether a certain number already present

  • 0

In my project. I am trying to check whether a certain number already present in any other adjacent div‘s which are present in a parent div.

  //generated dynamically using jQuery
  <div> //parent div
      //many div's
      //one of the child div is selected by the user.
  </div>
  <div> //another parent div
     //my function is checking one of these div's instead of the above, rarely
  </div>

I used the following below code. but it sometimes(rarely) selecting the another parent div‘s child elements which I dont want to check for (I checked with debugger in chrome). and if sometimes even if the function selects the correct parent div it is always selecting the same child div element which is selected by the user.

jQuery

function checkInGroup(){
    var selectedDiv = $('#' + _selectedDivId); //updated after engineer's comment
    selectedDiv.parent("div").children().each(function(){
        debugger;
        if(this !== selectedDiv[0]){ //selecting the same div
            var self = $(this);
            if(self.text() == _randomNumber){
                debugger; //never executing
                //do some function here
            }
        }
    });
}

EDIT: I am not sure why my code is not working when it is working fine in jsbin. I need to check why so.. It is always checking with the same user selected div?? Hence the function is not entering into the if statement..

The debugger which is present inside the if statement is never executing. and also the each function loop is happening only once with the same selected div (hence the function is not entering in to the if statement)

Here is the jsfiddle

  • 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-17T14:18:35+00:00Added an answer on June 17, 2026 at 2:18 pm

    Use siblings .

    $('#' + _selectedDivId).siblings().each(function(){
    
    });
    

    Updated:

    selectedDiv id is not actually div it is button id. that’s the problem. please
    change your code like below.

       selectedDiv.parent("div").parent("div").find("button").each(function(){
    

    demo

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

Sidebar

Related Questions

Has anyone had this unusual(recurring) experience before? I'm trying to check out the project
In my current project I'm trying to check a MySQL database: a MySQL database
Im working on a school project and i'm trying to check in GWT if
I'm trying to create a search method where I'm wanting to check whether the
My MVC 3 webapp has different parts which require to check whether the user
I'm trying to set up Cruise Control to build my project and check for
I am trying to make project of a web app that will check the
I am trying to check for the style='width:60%' bit in the html below <div
I was trying to check out a project from SVN using Eclipse. I tried
I'm working on a project and trying to use JavaScript for validating all inputs

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.