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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:16:44+00:00 2026-05-23T17:16:44+00:00

$(‘.HelpBoxOk’).live(‘click’,function() { var BoxHelpMain = $(this).parent().parent().parent().parent().parent().parent(); var ShouldFadeIn = false; //if the button says

  • 0
$('.HelpBoxOk').live('click',function()
{
    var BoxHelpMain = $(this).parent().parent().parent().parent().parent().parent();

    var ShouldFadeIn = false; //if the button says next then there is more divs to fadein if it says ok then no more divs to fade in i.e end of divs
    if($(this).attr('value') == 'Next')
    {
        ShouldFadeIn = true;
    }

    BoxHelpMain.fadeOut().queue(function() //fadeout the current div
    {
        if(ShouldFadeIn == true) // if it should fade in next div
        {
            FadeinNextDiv   = false;
            AllBoxHelpMain  = $(document).find("[id^=BoxHelpMain]"); // find all div with the same id as current one 

            if(AllBoxHelpMain.length) // if any divs with id exists 
            {
                AllBoxHelpMain.each(function()  // loop through all the divs 
                {
                    if(FadeinNextDiv == true)  // if we need to fade in the next div 
                    {
                        $(this).fadeIn();
                    $(this).find("input[class^=HelpBoxOk]:first").focus();      // fade in the div          
                        FadeinNextDiv   = false;
                        return false;
                    }
                    if($(this).attr('id') == BoxHelpMain.attr('id') )   // if current div id matches the clicked box/div then the next box/div needs to be fadded in 
                    {                       
                        FadeinNextDiv = true;
                    }
                })          
            }
        }
    });
    return false;
});

Please help me rectify this crappy code. My requirement is there are many div whose id starts with BoxHelpMain having a button HelpBoxOk. Now on click of the helpBoxOk i want it to search for next BoxHelpMain in the entire doc and fadeout the current BoxHelpMain and fadein the next BoxHelpMain. If no other div is present then just fadeout the current one

None of theses divs are siblings and scattered across dom

  • 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-23T17:16:45+00:00Added an answer on May 23, 2026 at 5:16 pm

    Firstly, give all of your BoxHelpMain* divs the same class:

    <div id="BoxHelpMain1" class="boxhelp">
    

    Assuming that all such elements are at the same level in your DOM hierarchy (i.e. they’re all siblings) finding the next one then reduces to:

    var current = $(this).closest('.boxhelp');         // find button's parent
    var next = $(current).nextAll('.boxhelp').first(); // find next .boxhelp
    

    And your fading just becomes:

    $(current).fadeOut(function() {
        $(next).fadeIn();  // called when the .fadeOut() completes
    });
    

    There’s no need to check whether next exists or not – jQuery will just ignore the empty list.

    If they’re not siblings, try this:

    var $current = $(this).closest('.boxhelp');  // find button's parent
    var $next = $();                             // an empty jQuery object
    
    var $all = $('.boxhelp');
    for (var i = 0; i < $all.length - 1; ++i) {
        if ($all.get(i).is($current)) {
            $next = $all.get(i + 1);
            break;
        }
    }
    

    and then fadeout as above.

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

Sidebar

Related Questions

I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Hi if i run my project its indicate this logcat error...how to solve this
Does anyone know how can I replace this 2 symbol below from the string
I need a function that will clean a strings' special characters. I do NOT
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
I was writing code for dragging mechanism which invokes to wait for small period
I've got a string that has curly quotes in it. I'd like to replace
I downloaded PostgreSQL from the official website and ran the .dmg installer. After that
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.