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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:14:44+00:00 2026-06-06T17:14:44+00:00

If you have a regular link in HTML, you can get the value of

  • 0

If you have a regular link in HTML, you can get the value of its href attribute using jQuery’s attr function:

<a id="testLink" href="test/link.html">Test Link</a>`

>>> $('#testLink').attr('href');
testLink.html

Example:

  • http://jsfiddle.net/63RsQ/1/

However, if the link was created using jQuery, then in IE 7, this function returns the absolute URL that the browser would access if you clicked on the link (e.g. https://stackoverflow.com/questions/ask/testLink.html), instead of the literal value of the href attribute.

Example:

  • http://jsfiddle.net/xtrEB/10/

I’ve also tried this, this.href, and this.getAttribute('href'), and they all return an absolute URL.

Is there any way to get the literal value of the href attribute of a link created by jQuery in IE 7?

  • 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-06T17:14:47+00:00Added an answer on June 6, 2026 at 5:14 pm

    If you are creating the link in a way that jQuery is forced to use .innerHTML, it will work not properly and is documented in: http://api.jquery.com/html/ (also http://api.jquery.com/jQuery/#creating-new-elements) :

    This method uses the browser’s innerHTML property. Some browsers may
    not generate a DOM that exactly replicates the HTML source provided.
    For example, Internet Explorer prior to version 8 will convert all
    href properties on links to absolute URLs, and Internet Explorer prior
    to version 9 will not correctly handle HTML5 elements without the
    addition of a separate compatibility layer.

    To fix it, create the link in a way that doesn’t force jQuery to use .innerHTML:

    $('#test').append( $("<a>", {href: "test/link.html", text: "Test Link"}));
    

    http://jsfiddle.net/xtrEB/12/

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

Sidebar

Related Questions

Anybody have a regular expression to replace the following code: <a href=originalLink>hi</a> with: <a
I have a regular UITableViewController and a UITableView as its only view, and I
I have written regular expression which converts text links into clickable link. The code
i have a regular html Grid and i am binding my asp.net mvc view
I have the following site and I want with regular expressions to get the
I'm getting more into jQuery and so have set up a HTML/Javascript/CSS base site
I'm having an issue creating a link like <a href=javascript:window.open('www.microsoft.com');>Visit Microsoft</a> using stringbuilder. I
I have a jQuery colorpicker that the visitor can change and I am trying
I have a regular texbox control. I need to highlight some words with a
I have a regular expression to match anything between { and } in my

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.