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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:06:30+00:00 2026-05-20T06:06:30+00:00

var tab1 = $(‘.tabs a:first-child’).attr(‘href’); alert(tab1); .. matches only one although there are two

  • 0
var tab1 = $('.tabs a:first-child').attr('href');
alert(tab1);

.. matches only one although there are two div.switch on the same page. The second is down on the page, not in the same parent.

Edit: Basically my question is, :first-child should find all the elements, but it just stops after one like :first

  • 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-05-20T06:06:30+00:00Added an answer on May 20, 2026 at 6:06 am
    $('.tabs').each(function() {
     alert($('a:first-child', $(this)).attr('href'));
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<a href=#tab1>Tab1</a> <div id=tab1>content</a> ... var a = $(this).attr('href'); $(a).show(); This works but only
Here's the relevant HTML: <div id=navcontainer> <ul id=navlist> <li><a href=#tab1>Item one</a></li> <li><a href=#tab2>Item two</a></li>
Example: Here we have <p class=tab1 current></p> How can I get only the first
JavaScript: $('.addTable').live('click', function () { var appendTxt = <table id='tab1'> <tr><td><input type='text' name='input1' /></td><td><input
var SalesforceOAuthPlugin = { /** * Obtain authentication credentials, calling 'authenticate' only if necessary.
var search= document.getElementById('appMenu').value document.location.href= '${createLink(controller: 'application' , action:'ajaxAppSearch', params: ['query': search])}' The element appMenu
HTML: <ul id=mode> <li><a href=#tab1>tab1</a> <div class=extra>tada</div> </li> <li><a href=#tab2>tab2</a> <div class=extra>tada</div> </li> </ul>
HTML: <ul> <li><a href=#tab1>tab1</a></li> <li><a href=#tab2>tab2</a></li> </ul> <div id=tab1 class=tab-content>content 1</div> <div id=tab2 class=tab-content>content
Here is my markup: <ul class=tab1> <li><a href=http://site.com/some.html?param=1></li> <li><a href=http://site.com/some.html?param=2></li> <li><a href=http://site.com/some.html?param=3></li> ... </ul>
Below is the jquery code I am using for my AJAX tabs Is there

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.