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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:37:27+00:00 2026-05-30T10:37:27+00:00

Ok my HTML markup is as follows: <div class=refine_search_box> <div class=heading>Refine Search</div> <div class=section_heading><a

  • 0

Ok my HTML markup is as follows:

<div class="refine_search_box"> 
    <div class="heading">Refine Search</div>   

    <div class="section_heading"><a href="#">By Size</a></div>
    <div class="section">
            @Html.DropDownListFor(m => m.Size, new SelectList(Model.SizeList, "key", "value", Model.Size), "")
    </div>

    <div class="section_heading"><a href="#">By Sport</a></div>
    <div class="section">
            @Html.DropDownListFor(m => m.Sport, new SelectList(Model.SportList, "key", "value", Model.Sport), "")
    </div>
</div>

My Jquery is as follows:

$(document).ready(function () {
    $("div.section").toggle();

    $(".refine_search_box a").click(function (e) {
        var $this = $(this);
        var $div = $this.prev().nextAll(".section").first();
        $this.toggleClass("selected");
        $div.toggle();
        e.preventDefault();
    });
});

What I want to happen is when the link in the .section_heading is clicked I want the .section div to open thats directly after it. But my jQuery always returns nothing for $div, I thought this would be quite simple but I’m obviously missing something obvious. I’m very new to jQuery so apologise if its stupidly simple!

Cheers.

  • 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-30T10:37:28+00:00Added an answer on May 30, 2026 at 10:37 am

    I think you need to use .parent() instead of .prev():

    $(".refine_search_box a").click(function (e) {
        var $this = $(this);
        var $div = $this.parent().next();
        $this.toggleClass("selected");
        $div.toggle();
        e.preventDefault();
    });
    

    This is assuming that ‘.refine_search_box’ surrounds all of your section_heading divs.

    You can also just use .parent().next() as long as your html stays the same.

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

Sidebar

Related Questions

Suppose I have this html markup: <div id=wrapper> <pre class=highlight> $(function(){ // hide all
I have the following HTML markup: <body> <div class=wrapper> <div class=head> <p class=title>title</p> <a
I have the following HTML markup : <a class=link1 href=javascript:load(0,1);>Click here</a><span class=loader></span> The load
I have the following html markup on my page, <div id=sig_container> <div id=layer1 class=layer
My html markup is as below: <ul class=top-nav> <li id=page-1><a href=/>HOME</a> <ul class=page-1 current>
I have the following html: HTML markup <ul id=test> <li><a href=http://www.yahoo.com>yahoo</a></li> <li><a href=http://www.google.com>Google</a></li> </ul>
Existing markup: <g:textField name=identifier/> <g:remoteLink action=newId update=identifier>generate new id</g:remoteLink> Corresponding HTML markup: <input type=text
I'm trying to create css buttons by using the following html markup: <a href=access.php
I'm rendering a drop down list using Html.DropDownListFor() extension. The markup I get is
I can select (using jQuery) all the divs in a HTML markup as follows:

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.