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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:05:52+00:00 2026-06-05T05:05:52+00:00

LIVE SAMPLE I’m tryign to write a basic click filter script in jQuery to

  • 0

LIVE SAMPLE
I’m tryign to write a basic click filter script in jQuery to find 3 classes print, video, web and toggle them on and off. I have 1 click listener referencing 4 ids:#printInteract, #webInteract, #videoInteract, #allInteract

Problem
After click I want to toggle the parent .box that containes the one or more of the classes the toggle. Unfortunatly, my click event removes the refernced ids and not the parent .box

*how can I grab the parent(it’s not the direct parent || check htmlbox) .boxand hide/show it?

jQuery

$(document).ready(function () {

//attach a single click listener on li elements
$('li.navCenter').on('click', function () {

    // get the id of the clicked li
    var id = $(this).attr('id');

    //conditional cases
    if (id == 'printInteract') {
        $(".box").find('.web, .video').hide();
        $(".box").find('.print').show();
    }
    if (id == 'webInteract') {
        $(".box").find('.print, .video').hide();
        $(".box").find('.web').show();
    }
    if (id == 'videoInteract') {
        $(".box").find('.print, .web').hide();
        $(".box").find('.video').show();
    }
    if (id == 'allInteract') {
        $(".box").find('.video, .print, .web').show();
    }
});
});  

BOX HTML

<div class="box">
<h1 title="Light me up"></h1>
<div class="innerbox">
    <figure>
        <img src="#"
        />
    </figure>
    <ul class="categorySelect">
        <li class="print"></li>
        <li class="video"></li>
    </ul>
</div>

html navigation

  <li id="allInteract" class="navCenter">
    <a id="activeAll" class="navBg" href="#"><div class="relativeCenter"><img src="asset/img/logo30px.png" /><h3>all</h3></div></a>
</li>
<li id="printInteract" class="navCenter">
    <a id="activePrint" class="navBg" href="#"><div class="relativeCenter"><img src="asset/img/print.gif" /><h3>print</h3></div></a>
</li>
<li id="videoInteract" class="navCenter">
    <a id="activeVideo" class="navBg" href="#"><div class="relativeCenter"><img src="asset/img/video.gif" /><h3>video</h3></div></a>
</li>
<li id="webInteract" class="navCenter">
    <a id="activeWeb" class="navBg" href="#"><div class="relativeCenter"><img src="asset/img/web.gif"  /><h3>web</h3></div></a>
</li>

PS: would anyone know how to add a fadein out transition to this also? 🙂

  • 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-05T05:05:53+00:00Added an answer on June 5, 2026 at 5:05 am

    Perhaps you’re looking for .closest() :

    $(this).closest('.box').hide();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the AVFoundation classes to capture the live video stream from the camera
Sample Page. http://newsite.702wedding.com/live/linktovideo.asp I need the 4 links to load streaming video feed in
Live streaming video in html 5 - what is required from server to stream
I am using 'live' function to do some on-click stuff on table rows, i.e.
When trying to run the sample code here: http://www.nikhilk.net/Live-Search-REST-API.aspx I get: Error 52 The
I'm using FMLE 3.1 to stream live video encoded with H.264 format with FMS
I create a sample Live wallpaper application, My requirement is, the Live-wallpaper have a
I'm diving into writing a mobile app with jQuery Mobile/PhoneGap. I'm using this sample
$.each(data, function(i,data) { ...[cut]... +<a id=\contact_+data.id+_delete\ href=\/user/contact/delete/ticket_id/+data.ticket_id+/contact_id/+data.id+\>Delete</a> ...[cut]... $(#contact_+data.id+_delete).live('click',function() { var href = this.attr('href');
Using Fiddler and also Live HTTP Headers I tried to find out how Firefox

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.