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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:08:43+00:00 2026-06-08T23:08:43+00:00

I have written this jquery code : <script type=text/javascript> $(document).ready(function () { var university

  • 0

I have written this jquery code :

    <script type="text/javascript">
    $(document).ready(function () {
        var university = { title: 0, href: 1, link: 2 };
        var universities = [];
        $(".aname").each(function (key, value) {
            university.href = value.all[0].href;
            university.title = value.all[0].innerHTML;
            university.link = value.parentNode.all[2].all[0];
            universities[key] = university;                
        });
       debugger; // now if you watch universities this only last item.
    });
</script>

It should save all university objects in to array of universities it works but it replace only the last item in to all items after $.each I don’t know why?

  • 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-08T23:08:45+00:00Added an answer on June 8, 2026 at 11:08 pm

    How about:

    var universities = $( '.aname' ).map(function () {
        return {
            href: this.all[0].href,
            title: this.all[0].innerHTML,
            link: this.parentNode.all[2].all[0]       
        };
    }).get();
    

    However, I don’t think the all collection is cross-browser. In that case, consider replacing it by jQuery’s traversing methods, or native ones. For instance, if all[0] selects the first child (does it?), then you can write this.children[0] or $( this ).children( ':first' ).

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

Sidebar

Related Questions

This is the piece of code I have written: <html> <head> <script type=text/javascript src=jquery-min.js></script>
I have written this code in JavaScript and works perfectly fine when I include
I have written a Javascript/jQuery script. Its purpose is to serve as a responsive
I'm learning javascript and jquery and have written a very basic script inside my
I have written this code to benchmark jQuery vs DOM performance. The performance is
I have this AJAX submission form written with the jQuery validation plugin. It all
I have written this code inside a servlet to delete certain records from three
I have written this function to auto correct gender to M or F from
I have written this code what it does is if user types postcode or
I have written this code outside all functions: int l, k; for (l =

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.