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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:06:12+00:00 2026-05-19T03:06:12+00:00

I have a situation where an element contains n clickable handles and n revealable

  • 0

I have a situation where an element contains n clickable handles and n revealable elements:

<div class="revealer">
  <div class="hotspot">
    <a class="handle" href="javascript:;">A</a>
    <div class="reveal">
      <p>Content A.</p>
    </div>
    <div class="reveal">
      <p>Content B.</p>
    </div>
  </div>
</div>

When I click ‘handle’, it shows both ‘reveal’ elements. This works fine. This chunk of code is dropped into a given document wherever the creator wants. Including… inside another <div class="reveal"></div> element. The ability to nest these revealer objects is reasonable, and useful in my case.

What I’m stuck on, is a decent way to only handle only immediate <div class="reveal"></div> elements, and not nested ones (otherwise clicking on the outer handle would reveal alll nested reveals).

So here’s the example structure:


<div class="revealer">
  <div class="hotspot">
    <a class="handle" href="javascript:;">A</a>
    <div class="reveal">
      <p>Content A.</p>
    </div>
    <div class="reveal">

        <p>Content B.</p>

        <!-- nested revealer -->
        <div class="revealer">
          <div class="hotspot">
            <a class="handle" href="javascript:;">A</a>
            <div class="reveal">
              <p>Sub-content A.</p>
            </div>
            <div class="reveal">
              <p>Sub-content B.</p>
            </div>
          </div>
        </div>
        <script type="text/javascript"> // a setup script which instantiates a Module object for this revealer, which controls all revealing </script>

    </div>
  </div>
</div>
<script type="text/javascript"> // a setup script, which instantiates a Module object for this revealer, which controls all revealing </script>

I heavily use the YUI2.8.2 framework, so right now I have a test in place when you click a handle to collect a set of its own revealers and show them, but excluding nested reveals, which should be actioned by their own instantiated module, not the parents’.

The Javascript test is as follows:

    // grab all 'reveal' elements to show
    var reveals = yd.getElementsBy(function(el){
            if( yd.hasClass(el, REVEAL_CLASS) && pObj.isChild( el ) ){
                return true ;
            }
            return false;
    }, null, this.root() );


    // the test method above is "isChild( el )", the 'el' arg is a 'handle' inside a 'hotspot', so I have...

isChild: function( el )
{
    var ancestor = yd.getAncestorBy( el, function(nestedEl){
        return yd.hasClass(nestedEl, REVEALER_CLASS);
    });

    // ancestor is the immediate parent 'reveal' element
    var forefather = yd.getAncestorBy( ancestor, function(nestedEl){
        return yd.hasClass(nestedEl, REVEALER_CLASS);
    });

    // forefather is 
    if(forefather){
        // Yuck yuck yuck, get rid of this dependency on a custom className :(
        if(!yd.hasClass(this.getRoot(), 'revealer-nested') ){
            return false ;
        }
    }
    return true ;
},

But all I can muster is to add a new class name, revealer-nested, to a nested revealer element… but I really don’t want to have to do that, because these objects are supposed to exist in their own context and not care or be affected by parent revealers.

… I hope that isn’t tmi, please ask any required questions etc for more info – I may have missed out some contextual info as I’m right in the middle of refactoring this module.

Many, many thanks in advance.

EDIT:
It’s also quite important that I don’t start relying on descendant properties like parentNode, childNode[x], nextSibling, etc … because currently this module is quite flexible in that its ‘reveal’ and ‘handle’ elements can reside within other markup and still be targeted – so long as they’re found inside a ‘hotspot’.

  • 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-19T03:06:13+00:00Added an answer on May 19, 2026 at 3:06 am

    There is a CSS3 selector :not() which allows you to filter out elements from a selection. I know jQuery can select a set of elements by CSS3 selector, for example:

    $('.revealer:not(.revealer > .revealer)')
    

    I think that would work as a selector to only select elements of class “revealer” which aren’t children of class “revealer”.

    This all depends on YUI being able to support CSS3 selectors to select sets of elements (if you’re definitely only using YUI).

    Does that help? I think that’s what you were asking…

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

Sidebar

Related Questions

I have the following situation: A stackpanel contains a number of elements, including some
I have a situation where i need element id of div where action happened.
I have a situation where all my selectors all have the same ancestor element
I have a situation where particular elements (xs:simpleType, xs:complexType) are placed in the output
i have situation like this: class IData { virtual void get() = 0; virtual
I have an element that contains two span tags that each contain some text.
I have this situation where i want to call a certain element depended on
I can't figure out how to handle the following situation: I have a 9*9
Situation: I have a simple XML document that contains image information. I need to
Hey guys, I have a UL like so: <ul id=list> <li class=something> <div class=btns

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.