0

I'm using a bit of script based on Changing div content based on scroll position

I just want to make part of the text (which changes) include some varying hyperlinks. For example as you scroll it shows a link to Google at one point, and then when you scroll past another div it shows a link to Twitter .etc.

I thought it would be simple as embedding it within the classed text, just like below..

<p class="description" style="display: none;">This is <a href="http://www.twitter.com">Twitter</a></p>

However as you can see in this jsfiddle: http://jsfiddle.net/6RHys/56/, the text will change, but the hyperlink does not work.

Would anybody have an idea as to how this is possible ?

Community
  • 1
  • 1
user3358714
  • 109
  • 2
  • 12

2 Answers2

1

instead of text()

$('#date').html($(this).find('.description').text());

use html()

$('#date').html($(this).find('.description').html());
Amit Soni
  • 1,402
  • 1
  • 9
  • 15
0

I think this is because you use the .text() function which just gives you the innerText with HTML stripped out. It should work if you use .html() instead.