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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:13:44+00:00 2026-05-18T07:13:44+00:00

I think I’ve almost got it, but I’m newish to jQuery and must be

  • 0

I think I’ve almost got it, but I’m newish to jQuery and must be overlooking what the problem is.

Here is my code.

// <![CDATA[

var root = null;

$(document).ready( function(){

    $.get( "/_assets/xml/sitemap.xml", 
        function( data ) {
            root = data;
            var pathname = window.location.pathname;

            var local_url = "*[url=" + pathname + "]";
            var currpage = $(root).find(local_url).attr("name");
            var parentEls = $(root).find(local_url).parents();

            var mapped = $(parentEls).map(function () { 
                  var element = $(this).attr("name");
                  var element_url = $(this).attr("url");
                  var element_wrap = $(element).wrap('<a href=' + element_url + '/>');
                  return element_wrap; 
                    })
                .get()
                .reverse()
                .join(" / ");

            $("#breadcrumb").append("<p>" + mapped + " / " + currpage + "</p>");

        } );
} );

// ]]>

Here is where I’m having trouble:

var mapped = $(parentEls).map(function () { 
                  var element = $(this).attr("name");
                  var element_url = $(this).attr("url");
                  var element_wrap = $(element).wrap('<a href=' + element_url + '/>');
                  return element_wrap; 
                    })

What I’m trying to do is wrap each element in an <a> tag and assign href=element_url. But I keep getting errors. Can anyone see a fix? Thanks!

  • 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-18T07:13:45+00:00Added an answer on May 18, 2026 at 7:13 am

    Quick stab at it:

    var element_wrap = $(element).wrap('<a href="' + element_url + '" />');
    

    The change is the double quotes – you were producing a string like this:

    <a href=http://somewhere.come />

    but you wanted

    <a href="http://somewhere.come" />

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

Sidebar

Related Questions

I think it will be very hard for you to read the code but
I think most people here understand the importance of fully automated builds. The problem
Think my problem is I am trying to sum a count in the same
I think I've figured out the problem. I'm using a IP webcam stream, doing
I think I have a basic understanding of this, but am hoping that someone
I think this could be a very easy question for you. But I have
Think of these lines of code : @boss_locations = BossLocation.order('min_level asc').all @discovered = current_user.discovered_locations.includes(:boss_location).all
Think of the following code: static int Main() { byte[] data = File.ReadAllBytes(anyfile); SomeMethod(data);
I think this has probably been asked, but after reading a lot, I'm not
I think I'm missing something basic here. Why is the third IF condition true?

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.