1

I have no clue how to make this link into a hyperlink in Jquery. I am new to the language and cannot figure it out. I have done a lot of research and still no luck. Here is what I have:

content:" <div class='map_dir'><span class='dir'>Get Directions: </span>https://goo.gl/maps/N7fmt</div></div>"

How am I able to get the google maps link turn into a clickable hyperlink?

Thanks so much in advance, Michael

  • possible duplicate of [Best way to create a link using JQuery?](http://stackoverflow.com/questions/4261687/best-way-to-create-a-link-using-jquery) – Peanut May 04 '15 at 07:32
  • http://learn.jquery.com/using-jquery-core/manipulating-elements/#creating-new-elements – Alasjo May 04 '15 at 07:33

2 Answers2

1

Just replace
https://goo.gl/maps/N7fmt
with
<a href='https://goo.gl/maps/N7fmt'>https://goo.gl/maps/N7fmt</a>

Sanchit
  • 541
  • 2
  • 18
  • WOW! That easy?!? I am embarrassed. Thank you so very much! –  May 04 '15 at 07:37
  • Nthing to be embarassed...nobody is born perfect.. you will learn soon. Please +1 and accept answer if it works. – Sanchit May 04 '15 at 07:39
  • I accepted answer, however I am not able to +1 cause I do not have enough reputation. Thanks again! –  May 04 '15 at 07:51
0

You just have to use the anchor element (""). I've created an example:

$("div").html(
  "<div class='map_dir'>GetDirections: <a href='https://goo.gl/maps/N7fmt' class='dir'>https://goo.gl/maps/N7fmt</a></div>");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div></div>

We're placing a wrapped anchor into the DIV element. http://api.jquery.com/html/

Sanchit
  • 541
  • 2
  • 18
OddDev
  • 3,644
  • 5
  • 30
  • 53