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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:09:07+00:00 2026-06-06T17:09:07+00:00

Alright this is my first day with JQuery so have fun with these functions

  • 0

Alright this is my first day with JQuery so have fun with these functions I made. I’m trying to hide a div (#panel) when different triggers are clicked. Below is three functions in which all three of them need to hide (#panel) when used. The way I have it setup it’s only working for the first function. The other two don’t hide the element. So without further ado.

jQuery(document).ready(function($){
var $panel = $(this).closest(".panel-container").find(".panel");
$('#searchsubmit').click(function(e){
    $('#boxes').empty();
    e.preventDefault();
    var $panel = $(this).closest(".panel-container").find(".panel");
    var search_val=$("#s").val();
    $.post(
        WPaAjax.ajaxurl,
        {
            action : 'loop_search',
            search_val : search_val
        },
        function( response ) {
            $('#boxes').append( response ).masonry( 'reload' );
            $panel.hide("slow");
            $('.trigger').removeClass("active");
            $('.trigger-loop').removeClass("active");
        }
    );
});
$('#fame.trigger-loop').click(function(){
var $panel = $(this).closest(".panel-container").find(".panel");
    $('.trigger').removeClass('active');
    $('.trigger-loop').removeClass('active');
    $('#fame.trigger-loop').addClass('active');
    $('#boxes').empty();
    $.post(
        WPaAjax.ajaxurl,
        {
            action : 'loop_fame'
        },
        function( response ) {
            $('#boxes').append( response ).masonry( 'reload' );
            $panel.hide("slow");
        }
    );
});
$('#new.trigger-loop').click(function(){
var $panel = $(this).closest(".panel-container").find(".panel");
    $panel.hide("slow");
    $('.trigger').removeClass('active');
    $('.trigger-loop').removeClass('active');
    $('#new.trigger-loop').addClass('active');
    $('#boxes').empty();
    $.post(
        WPaAjax.ajaxurl,
        {
            action : 'loop_new',
        },
        function( response ) {
            $('#boxes').append( response ).masonry( 'reload' );
            $panel.hide("slow");
        }
    );
 });

});

//–html

<li>
 <a id="fame" class="trigger-loop active" href="#"><div id="fame-icon"></div></a>
</li>
<li>
 <a id="new" class="trigger-loop" href="#"><div id="gold-artist"></div></a>
</li>
<li>
 <div class="panel-container">
  <div class="panel">
     <----content----->
  </div>
  <a class="trigger" href="#"><div id="playlist-icon"></div></a>
 </div>
</li>
<li>
 <div class="panel-container">
  <div class="panel">
     <----content----->
  </div>
  <a class="trigger" href="#"><div id="random-icon"></div></a>
 </div>
</li>
  • 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-06T17:09:09+00:00Added an answer on June 6, 2026 at 5:09 pm

    The problem is that you have a global variable which is being overwritten and causing undesired affects.

    var $panel = $(this).closest(".panel-container").find(".panel");
    

    That line will set $panel as a global variable since it has no parent scope aside from document.ready. When you are inside one of the callback closures, there is a conflict of interest when $panel is defined again. Consider changing these names to remove the conflict.

    The result is calling the global $panel when inside of

    function( response ) {
            $('#boxes').append( response ).masonry( 'reload' );
            $panel.hide("slow");
     }
    

    instead of calling the localized version you were thinking of. That is why only one of them is hiding.

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

Sidebar

Related Questions

Alright, I'm at my wit's end on this issue. First, backstory. I'm working on
Alright I know this is more than likely a amateur question but I have
Alright, this one's interesting. I have a solution, but I don't like it. The
Alright, this problem is a little complicated, so bear with me. I have a
Alright, this is melting my brain. It might have something to do with the
Alright, I have some weird behavior and this question goes to the people out
Alright, I have two files. They are the EXACT SAME. The first file is:
So I have been trying to get this to work 2 days and I
Alright, Ill try to explain this as best as I can first... My program
Alright, so I have a text file with some data in it, in this

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.