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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:21:08+00:00 2026-05-11T06:21:08+00:00

Heads up: I am quite new to Javascript and have so far only written

  • 0

Heads up: I am quite new to Javascript and have so far only written very basic scripts based on jQuery. I am a quick study though..

What I am after is a way to:

1) identify tags

2) read the img tags

3) wrap the tag with an <a href> tag with a dynamic link based on the src of the img.

Example:

<img src='../../img_T/Culture/C_01/c_01_abb_005.jpg' width='310' height='180' alt='image1'> 

should become

<a href='../../img_L/Culture/C_01/c_01_abb_005.jpg'><img src='../../img_T/Culture/C_01/c_01_abb_005.jpg' width='310' height='180' alt='C 01 Abb 005'></a> 

I am thinking that reading the src of each image and writing it to a variable, then reading that variable and replacing the /img_T/ with /img_L/ and then writing that to a new variable which can then be simply added to each href.

This is how far I have gotten, but this does not work at all:

/* in the comments 'xxx' represents a different unique image string */ /* This should get the <img src='../img_T/xxx' /> string as text and store it. */ var $imgSrc        =    $('.displaywrapper img').attr('src');  /* This part should use the above sourced <img src='../img_T/xxx' string and replace ../img_T/ of the src with ../img_L/ and store it in var = imgLink. */ var imgLink        =    $imgSrc.text().replace('img_T','img_L');  /* This part should then wrap the <img src='../img_T/xxx' /> so it becomes <a href='..img_L/xxx'><img src='../img_T/xxx' /></a> */ $('.displaywrapper img').each(function(){.wrap('<a href='imgLink'></a>')}); 

Thanks for reading. Jannis

  • 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. 2026-05-11T06:21:09+00:00Added an answer on May 11, 2026 at 6:21 am

    I think this should do the trick:

    $(document).ready(function() {     $('.displayWrapper img').each(function() {         var src = $(this).attr('src').replace('img_T','img_L');         var a = $('<a/>').attr('href', src);         $(this).wrap(a);     }); }); 

    Line 1: Wait for the document to be ready before doing anything..
    Line 2: Loop through each image using jQuery’s each function.
    Line 3: Get the current image’s src with attr and replace img_T with img_L
    Line 4: Dynamically create a new <a> tag and set it’s href attribute to the src in Line 3
    Line 5: wrap the <a> tag around the <img> tag.

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

Sidebar

Ask A Question

Stats

  • Questions 65k
  • Answers 65k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Comet, described by Brian is a nice technique, but requires… May 11, 2026 at 11:03 am
  • added an answer I think that the query has some typos, or was… May 11, 2026 at 11:03 am
  • added an answer Here's a link that might help: http://varjabedian.net/archive/2008/07/29/casting-a-byte-array-into-structures-in-c.aspx May 11, 2026 at 11:03 am

Related Questions

Anyone know off the top of their heads how to convert a System.Xml.XmlNode to
Just wondering if anyone knew off the top of their heads if there was
I need to programmatically determine out how many sectors, heads, and cylinders are on
Git has a much-touted(?) octopus-merge capability that can merge many heads into one. But
I'm looking to get data such as Size/Capacity, Serial No, Model No, Heads Sectors,
I'm reading through head first design patterns at the moment and while the book
After reading the Head First Design Patterns book and using a number of other
Just getting my head around Ruby metaprogramming. The mixin/modules always manage to confuse me.
Ive been smashing my head with this for a while. I have 2 completely
void addNewNode (struct node *head, int n) { struct node* temp = (struct node*)

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.