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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:00:56+00:00 2026-05-16T05:00:56+00:00

html <ul> <li><a href=# >Link</a> <ul> <li><a href=# >Link</a></li> <li><a href=# >Link</a></li> </ul> </li>

  • 0

html

<ul>
    <li><a href="#" >Link</a>
        <ul>
            <li><a href="#" >Link</a></li>
            <li><a href="#" >Link</a></li>
        </ul>
    </li>
</ul>​

jQuery

$(function(){
    $('ul').click(function(event){
        alert(event.target);
        return false;
    });
});

Can someone punch me to the head and tell me WHY on earth event.target is giving me a url when I click on anchors? I’m expecting it to give me [object HTMLAElement]. Just like [object HTMLLIElement] when you click li element. sample fiddle.


I have read this link, jquery-anchor-click-this-e-target-returns-url, but doesn’t seem to answer my question.

  • 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-16T05:00:56+00:00Added an answer on May 16, 2026 at 5:00 am

    Everything is ok! It’s just a representation of any link. You can still use event.target.href or even event.target.id and so on.

    Some elements, such as HTMLAnchorElement, have special toString functions that prevent you from finding their class name easily. If you type javascript:alert(document.links[0]) in the location bar, you will see the URL of the first link instead of its class name. The way to get around this problem is to use the default toString function on the object document.links[0], like so: javascript:alert(window.toString.apply(document.links[0])).

    From here.

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

Sidebar

Related Questions

I'm using jQuery + one click event + <a href... class=opener> (you can see
<script type=text/javascript> $(function() { $('#wp-calendar a').click(function(event) { event.preventDefault(); var url = $(this).attr('href') + '
I'm trying to get href value using jQuery: <html> <head> <title>Jquery Test</title> <script type=text/javascript
Is it possible to disable the jquery click when a href link (inside the
Is it possible to somehow place a whole HTML table in a href link?
there is a script in my html tag <script type=text/javascript> function setTaxDisplay(display) { window.location.href
The following java-script is working fine (Jquery) $(document).ready(function(){ $('#c_area').load($('.m_top:first').attr('href')) }); $('.m_top').click( function(){ $(#myDiv).html('<img src=images/loading.gif
I have a div containing a href. The div has a jQuery live click
I have the following two functions that work great: $(function(){ $('.trash_can a.delete').live('click', function(event) {
Still new to jQuery, need help on following: <!DOCTYPE html> <html lang=en> <head> <meta

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.