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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:10:23+00:00 2026-06-18T23:10:23+00:00

I have the following jQuery: $(.score-window a:first-child).click(function() { $(.score-window).hide(); $(.login-window).show(); }); $(.score-window a:nth-child(2)).click(function() {

  • 0

I have the following jQuery:

    $(".score-window a:first-child").click(function() {
        $(".score-window").hide();
        $(".login-window").show();
    });

    $(".score-window a:nth-child(2)").click(function() {
        $(".score-window").hide();
        $(".register-window").show();
    });

Which is hooked up to the following HTML:

        <div class="score-window">
            <i class="icon-remove" title="Close"></i>
            <p>In order to view your score, you have to <a href="#">log in</a>.</p><br>
            <p>Don't have an account yet? <a href="#">Register</a>! Totally free and you'll get the ability to save your scores.</p>
        </div>

I only have two links in the score-window class, so I don’t see why this isn’t working.

  • 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-18T23:10:24+00:00Added an answer on June 18, 2026 at 11:10 pm

    You have two links, but each one is the only child of its parent p, so they will match a:first-child only. The parent of the links is not .score-window, but p. However the parent of the p elements (along with the i and br elements) is .score-window.

    You need to amend your selectors to use :nth-child() with the p elements instead, then select the a under each one. There’s an i which is the first child, and a br between your two p elements which looks like it isn’t needed. You should be able to remove it then do this:

    $(".score-window p:nth-child(2) a").click(function() {
        $(".score-window").hide();
        $(".login-window").show();
    });
    
    $(".score-window p:nth-child(3) a").click(function() {
        $(".score-window").hide();
        $(".register-window").show();
    });
    

    If the br must stay there for whatever reason, use p:nth-child(4) or p:last-child instead for your second selector.

    If you’re using or can upgrade to jQuery 1.9, you can use :nth-of-type() instead to limit the count to just your p elements (i.e. the first p and the second p), but older versions of jQuery don’t support it:

    $(".score-window p:nth-of-type(1) a").click(function() {
        $(".score-window").hide();
        $(".login-window").show();
    });
    
    $(".score-window p:nth-of-type(2) a").click(function() {
        $(".score-window").hide();
        $(".register-window").show();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following jQuery code. $(function() { $('.clickme').click(function() { $('.totalthing').slideToggle('slow','easeInOutQuart', function() { //
I have the following jquery script: $(function(){ $('#top-menu').on('click', 'a.change-menu', function(e){ e.preventDefault() $(#menu-change-div).load($(this).attr(href)); }); });
I have the following jquery code. var destTable = $(#numbers); $(document).ready(function() { $(#btnAdd).click(function() {
I have the following jquery code: $(document).ready(function() { $(body[class*=page-calendar-practices] #content-header h1#title).after(<div id='athletics_practice-schedule'><div id='inner-title'><a href='www.example.com'
I have the following jquery function that submits to an iframe. The message sent
I have the following jquery code which doesn't work quite right when trying to
I have the following jQuery code: $(body.page-calendar-practices-2012-05 #content-header h1#title) which works fine. I can
I have the following controller which works fine: function Controller() {} Controller.prototype = {
I have the following jquery: function GetSelectedCheckboxIds(className) { var ln = className.length; return $('.'
I have the following jQuery which basically leaves the div at it's normal CSS

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.