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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:36:39+00:00 2026-06-07T18:36:39+00:00

I am novice when it comes to JQuery. To put it simply, I have

  • 0

I am novice when it comes to JQuery. To put it simply, I have four divs, of class “portlet-topper”. Each div has a sibling of the class “portlet-content”. This content is hidden, until an instance of portlet-topper is clicked. Once it is clicked, it’s sibling content is displayed. I use the following code:

$(".portlet-topper").click(function(e){
    e.preventDefault();
    $(this).siblings(".portlet-content").toggle();
});

To clarify before a click:

|—-portlet-topper-A—-|

|—-portlet-topper-B—-|

After A is clicked:

|—-portlet-topper-A—-|

Portlet Content of A

|—-portlet-topper-B—-|

If I click B, the content of B displays, and A’s is left displayed as well. If A has been clicked, I would like the clicking of B to display B while hiding A. How would I go about coding in this logic? I would need this to work for any number of divs, not just two. Essentially, allow only one set of portlet-content to be displayed at once. I figure I’d make explicit calls to show and hide, rather than toggle. Even still, I’m not really sure where to start…

Also, I am using Liferay, so I have little control over the class and id’s of each div. I can only manipulate the css or the javascript

  • 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-07T18:36:41+00:00Added an answer on June 7, 2026 at 6:36 pm

    I think you need to do this:

    $(".portlet-topper").click(function(e){ 
        e.preventDefault();
        $(".portlet-content").hide();
        $(this).siblings(".portlet-content").toggle(); 
    });
    

    Otherwise, you would never be hiding your contents.

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

Sidebar

Related Questions

I still consider myself quite a novice when it comes to JavaScript/JQuery. How would
I have a page in JQuery mobile, which contains a form. The form has
I am using jquery-ui tabs and dialog functionality. Each tab has a button on
I am a novice programmer when it comes to Java, I have Java:How To
So I'm a real novice when it comes to Jquery Mobile developement and I
I'm a complete novice when it comes to jQuery, so please bear with me...
I am very novice when it comes to MVC, jQuery and jqGrid. I am
Fairly novice when it comes to jQuery, so thanks in advance for bearing with
I am somewhat of a novice when it comes to jQuery and I am
I'm a novice when it comes to SQL and PHP, and I'm trying to

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.