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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:52:42+00:00 2026-06-04T14:52:42+00:00

I am a beginner when it comes to javascript/jquery ..so if this question sounds

  • 0

I am a beginner when it comes to javascript/jquery..so if this question sounds silly,please forgive me.

While going through this tutorial ,I tried to write to javascript console ,values of some of the variables in the functions-so that I can better understand how the function works

$(document).ready(function(){
    $("div.post h2 a").click(function () {
    var a    = $(this),
    href = a.attr('href'),
    content  = a.parent().next();
    console.log('a='+a);
    console.log('a.get(0)='+a.get(0));
    console.log('a parent='+a.parent());
    console.log('a parent.get(0)='+a.parent().get(0));
    console.log("href="+href);
    console.log('content='+content);
    content.load(href + " #content");
    return false; 
});

I have modified the html slightly

<div class="post">
    <h2 id="h21"><a href="other/mypage.html">My Page</a></h2>
    <div class="content">
        Teaser text1...
    </div>
</div>
<div class="post">
    <h2 id="h22"><a href="other/myotherpage.html">My Other Page</a></h2>
    <div class="content">
        Teaser text2...
    </div>
</div>
});

when I click on the first link,I get this console log output

a=[object Object]
a.get(0)=file:///home/me/dev/misc/other/mypage.html
a parent=[object Object]
a parent.get(0)=[object HTMLHeadingElement]
href=other/mypage.html
content=[object Object]

I thought the $(this) expression in the function would be the element which was clicked(ie the first <a element).Why does it appear as [object Object].I couldn’t make out how a.get(0) becomes file:///home/me/dev/misc/other/mypage.html

Similarly,shouldn’t the variable content be equal to the first div (containing Teaser text1)? Why does it appear as [object Object]?

  • 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-04T14:52:44+00:00Added an answer on June 4, 2026 at 2:52 pm

    I thought the $(this) expression in the function would be the element
    which was clicked(ie the first <a element).Why does it appear as
    [object Object].

    The variable a contains a jQuery object, and the toString method isn’t overridden for it, so it uses the default implementation that returns the type of the object.

    I couldn’t make out how a.get(0) becomes
    file:///home/me/dev/misc/other/mypage.html

    The get methods returns DOM element objects from the jQuery object, and the toString method for an <a> element returns the URL that the link points to.

    Similarly,shouldn’t the variable content be equal to the first div
    (containing Teaser text1)? Why does it appear as [object Object]?

    The variable content contains a jQuery element that contains the <div> element. Using content.get(0) would give you the DOM element.

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

Sidebar

Related Questions

I'm a complete beginner when it comes to Jquery, Javascript etc but I've managed
Im a bit of a beginner when it comes to javascript constructs. Im trying
Im a beginner when it comes to TDD and BDD. This is what I
Forgive my ignorance, but I am a beginner in java that comes from using
I think this is a beginner question, it is regarding the variable references across
I still consider myself a beginner when it comes to JQUERY+Coldfusion...so I'd like to
I'm very much a beginner when it comes to Javascript and would appreciate any
I am beginner when it comes to writing makefiles but I am having this
I'm a total beginner when it comes to computer languages, and was asked for
I am an absolute beginner when it comes to ActionScript and Flash. I am

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.