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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:01:05+00:00 2026-05-28T11:01:05+00:00

I have a link <ul class=sub_menu> <li><a href=caps>Caps</a></li> <li><a href=jeans>Jeans</a></li> <li><a href=shorts>Shorts</a></li> <li><a href=foootwear>Footwear</a></li>

  • 0

I have a link

<ul class="sub_menu">
    <li><a href="caps">Caps</a></li>
    <li><a href="jeans">Jeans</a></li>
    <li><a href="shorts">Shorts</a></li>
    <li><a href="foootwear">Footwear</a></li>
</ul>

I want to grab the href value, I tried the following code:

$(document).ready(function() {
    $('ul.sub_menu a').click(function() {
        var txt = $(this).attr('href');
        alert(txt);
    )};
)};

but I get this error

 The requested URL /new/caps was not found on this server.

I don’t want to grab the text, I have succeeded with that using .text();, I want the href value.

  • 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-28T11:01:06+00:00Added an answer on May 28, 2026 at 11:01 am

    Add return false to the end of your click event handler to stop the execution of the link.

    $(document).ready(function() {
        $('ul.sub_menu a').click(function() {
            var txt = $(this).attr('href');
            alert(txt);
            return false;
        )};
    )};
    

    You can also use event.preventDefault() if you want the event to still propagate up the DOM:

    $(document).ready(function() {
        $('ul.sub_menu a').click(function(event) {
            var txt = $(this).attr('href');
            alert(txt);
            event.preventDefault();
        )};
    )};
    

    Note: In a jQuery event handler, return false; is the same as calling event.preventDefault().stopPropagation();.

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

Sidebar

Related Questions

I have a link that I want to center vertically in the .well class
i have got <div><a class='link' href='index.php' data-container='target'>Load</a></div> <div class='target'></div> i need to write jquery
I have link for example domain.com/de/controler/action?param=value and I want make actionlink to keep same
I have the following page: <html> <head> <title>Kahil</title> <link rel=stylesheet type=text/css href=csshorizontalmenu1.css /> </head>
I have a link error where the linker complains that my concrete class's destructor
I have written a class using std::tr1::regex, and I don't know how to link
For edit home status of category I have a link: <span class=\ha\ title=\Active in
Suppose I have <table> <tr> <td><a class='ilink'> link text </a></td> <td></td> <td></td> <tr> <tr>
I have link that calls a function when clicked: <a href=javascript:spawnMenu(this); id=link1>Test1</a> To make
I have created a simple drop-down menu with JQuery, following a tutorial. LINK :

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.