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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:30:41+00:00 2026-06-12T17:30:41+00:00

While there is a lot of good resources on traversing the DOM with jQuery

  • 0

While there is a lot of good resources on traversing the DOM with jQuery I am not having any luck on my example.

On my site http://www.smithgrey.co.uk I have a series of thumbnail galleries all which have a ‘section title’ div in front of them.

What I want to achieve is when you click on the ‘section-title’ div the first <a href> link of the thumbnail to the right will clicked.

There are multiple instances of the class="section-title" – Unfortunately I am not able to add any ID or Classes as this is generated dynamically and have been asked to keep it as is if possible.

The HTML looks like this:

<body>
  <div id="content-grid">
    <div class="section-title">
      <span class="section-title-type">Title of the first thumbnail gallery</span>
    </div>

    <div class="index-article">
      <a href="#" class="fancybox">
        <img src="thumbnail-1">
      </a>
    </div>

    <div class="section-title">
      <span class="section-title-type">Title of the second thumbnail gallery</span>
    </div>

    <div class="index-article">
      <a href="#" class="fancybox">
        <img src="thumbnail-2">
      </a>
    </div>

    <div class="index-article">
      <a href="#" class="fancybox">
        <img src="thumbnail-3">
      </a>
    </div>

    <div class="index-article">
      <a href="#" class="fancybox">
        <img src="thumbnail-4">
      </a>
    </div>   
  </div>
</body>

And here is my jQuery so far but it does not yield the result I would imagine because it will click the link no matter if I click the first or second <div class="section-title">.

$('div.section-title').click( function(){
       $(this).parent().next($('div.index-article')).children('a.fancybox').click();
     });

Solution:

With the help of the other commentors I managed to figure out how to make it work as I expected:

$(document).ready(function() {
  $('div.section-title').click( function(){
    $(this).next('.index-article').find('a.fancybox:first').click();
  });
});
  • 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-12T17:30:43+00:00Added an answer on June 12, 2026 at 5:30 pm

    I will assume you have setup your jQuery correct with the appropriate ready event/etc. This is how I’d do it. Please note I’ve added a click event to the hyperlink to simulate the click in the jsfiddle example.

    http://jsfiddle.net/lucuma/s9mds/

    $('div.section-title').click(function(e) {
        $(this).next('div').find('a:eq(0)').click(); 
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While there are many good online and offline tools for testing regular expressions, I
This is related to another open question of mine . While there aren't any
I have been doing a lot of reading but not coming up with any
Is there any way to show a LOADING DIV while all the files (images,scripts,js
There seems to be a lot of fuss about multicore and java. While some
I have a click handler, which has event.preventDefault. There is whole lot of logic
While there are a handful of great programs for ISV Startups (BizSpark, Emplower ISV,
While there are many guides for Browser Helper Objects, i have a hard time
While there are multiple ways to reverse bit order in a byte, I'm curious
I can't wget while there is no path already to save. I mean, wget

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.