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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:53:03+00:00 2026-06-11T21:53:03+00:00

Well, im working on a lightweight simple dropdown. And I came out with this

  • 0

Well, im working on a lightweight simple dropdown. And I came out with this little problem:

<script>
$(document).ready(function () {
$('ul li:first a').click(function () {
    if ($(this).attr('class') != 'active') {
        $('.hideContent').slideUp(300);
        $('.showContent').removeClass('active');
        $(this).addClass('active').next('ul').slideDown(300);
        event.stopPropagation();
    }
    else {
        $(this).removeClass('active');          
        $('.hideContent').slideUp();
    }       
});
});
</script>

The :first is only triggering for the first ul. Im working with multiple uls right now:

    <ul>
    <li><a href="#"><span class="plus">+</span><span class="minus">-</span>Administração</a>
        <ul class="hideContent">
            <li><a href="#">Item</a></li>
            <li><a href="#">Item</a></li>
            <li><a href="#">Item</a></li>
            <li><a href="#">Item</a></li>
            <li><a href="#">Item</a></li>
        </ul>
    </li>
</ul>
    <ul>
    <li><a href="#"><span class="plus">+</span><span class="minus">-</span>Administração</a>
        <ul class="hideContent">
            <li><a href="#">Item</a></li>
            <li><a href="#">Item</a></li>
            <li><a href="#">Item</a></li>
            <li><a href="#">Item</a></li>
            <li><a href="#">Item</a></li>
        </ul>
    </li>
</ul>

The :first shouldnt trigger the first li of EACH ul? Or am I working the wrong way around?

Thanks in advance.

  • 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-11T21:53:05+00:00Added an answer on June 11, 2026 at 9:53 pm

    First only matches one element, try using :first-child instead.

    While this matches only a single element, :first-child can match more
    than one: One for each parent.

    http://api.jquery.com/first-selector/

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

Sidebar

Related Questions

This is a simple Captcha form which is working well and prints the requested
this is my viewDidLoad function working well : - (void)viewDidLoad { [super viewDidLoad]; //iAds
Simple function Date.parse() not working well in Internet Explorer 8 . I am using
I have a script working well for creating ad hoc iPhone builds. I can
This is sample of re-raise exception and working well try raise Exception.Create('Exception msg'); except
I have a simple CSS help popup that's been working well for me in
Good evening, I made a well working function with php, mysql and ajax. A
This code is working well: f = open(C:/Dokumente und Einstellungen/schnei17/Desktop/a.txt, r) f.seek(0) print f.read(200)
the admin form is working well but problem with the front end problem that
So I have this update panel and it is working well. <div> <button id=foo

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.