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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:48:20+00:00 2026-06-01T09:48:20+00:00

Logically, I want to embed an image in a link in a div. I’ve

  • 0

Logically, I want to embed an image in a link in a div. I’ve successfully done this with either the link or the image. I’ve even done it with the link and image in parallel (which is useless) for my purposes. But can’t seem to have the image wrapped in a link inside a div.

var div = OpenLayers.Util.createDiv();
var img = OpenLayers.Util.createImage(null, null, null, null, null, null, null, delayDisplay);
img.className = "olAlphaImg";
img.alt = altText;

var link = document.createElement("a");
// link.setAttribute("href", "#");
link.href="#" + altText;
link.appendChild(img);

div.appendChild(link); 

OpenLayers.Util.modifyAlphaImageDiv(div, id, px, sz, imgURL, position, border, sizing, opacity, altText);

return div;

This is for an OpenLayers where I’m trying to ensure keyboard navigation. I just am not sure how to do this with javascript and all the examples only use one appendChild reference. I’ve tried with innerHTML() but I wasn’t using strings so that didn’t seem useful.

  • 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-01T09:48:21+00:00Added an answer on June 1, 2026 at 9:48 am

    What do you mean by

    can’t seem to have the image wrapped in a link inside a div

    Do you experience any errors?

    I might have misunderstood your question, but if not, your code should work.

    Here’s my example: a working jsfiddle that wraps an image into a link into some container.

    var img = document.createElement('img');
    img.src = 'https://www.google.fr/images/srpr/logo3w.png';
    
    var anchor = document.createElement('a');
    anchor.href = 'http://google.com';
    
    // Wrap image in the link (anchor):
    anchor.appendChild(img);
    // Insert the anchor into container:
    document.getElementById('container').appendChild(anchor);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to do some updates, which logically looks like below - UPDATE t1
Let's say we want a RESTful web service to manage some logically nested resources,
I want to create a list of logically related RadioButtons. The RadioButtons are bound
I want to perform an SQL query that is logically equivalent to the following:
Basically I want to do this: delete top( 100 ) from table order by
I have nested groupboxes, which logically represent nested data structures in my application. Let's
So I have this array, and I want to delete strings that are 2
I want a table to logically size the columns according to the contents. Is
The web designer has given me HTML which looks like: <div .... style=background: transparent
We have a locally-developed triple store based on b-trees which I want to use

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.