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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:57:51+00:00 2026-05-20T04:57:51+00:00

I’m not sure if this is a jquery, javascript or simply a quirk in

  • 0

I’m not sure if this is a jquery, javascript or simply a quirk in the browser but consider this code:

for(rowIdx=0;rowIdx<theResultSet.rows.length;rowIdx++) {
  thisLine = $("#TestTemplateLI").clone().attr({'id':'test_'+rowIdx}).appendTo("#test_exerciseListUL");
  thisLine.find('[href*="#pageExercise_EXERCISENUMBER"]').each( function(i) {this.href = this.href.replace('EXERCISENUMBER', rowIdx)} );
}

The goal of the code above is to clone a list item (<LI>, embedded below) HTML fragment, modify it to address an anchor elsewhere on the page and then insert it into an unordered list (<UL>). All that works using the wonders of jquery. The problem is that once it’s been modified, the anchor doesn’t seem to work. Moreover after I mod the HREF programattically, it returns a full URL, not just an anchor reference. Example:

<UL id='testTemplate' style="display:none"> 
    <LI class='arrow' id='testTemplateLI'>
        <a href='#pageExercise_EXERCISENUMBER'>  <!-- THIS is the beast in question -->
            <DIV class='LABELCLASS test_labelContainer'>
                <TABLE height=100% width=100%>
                    <TR valign='center'><TD align='center'>EXERCISELABEL</TD></TR>
                </TABLE>
            </DIV>
            <IMG id='test_checkmark_EXERCISENUMBER' class='test_checkMark_off' src="assets/checkmark.png" width=60px height=54px>
            <DIV id='test_item_EXERCISENUMBER' class='test_exNameContainer'>
                <TABLE height=100% width=100%>
                    <TR valign='center'><TD>EXERCISENAME</TD></TR>
                </TABLE>
            </DIV>
        </a>
    </LI>
</UL>

So, two things are happening. One, the modified anchor is simply not working and two, what should modify from “href=’#pageExercise_EXERCISENUMBER’” to “href=’#pageExercise_0′” (or whatever the current row index (‘rowIdx’) is modifies it to: “href=’http://www.mydomain.com/themainpage.php#pageExercise_0&#8242;“.

I need a way to tell javascript to stop “helping” me on the href. As for issue #1, I think it’s related to #2.

Thanks in advance,

Scott.

  • 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-20T04:57:52+00:00Added an answer on May 20, 2026 at 4:57 am
    this.href
    

    Will return the fully-qualified URL that the anchor points to.

    You can use jQuery’s attr function to return what you want:

    var $this = $(this);
    $this.attr("href", $this.attr("href").replace('EXERCISENUMBER', rowIdx));
    

    Here‘s a good post explaining how .attr("href") is “normalized”

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
For some reason, after submitting a string like this Jack’s Spindle from a text
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small

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.