Chris W.
Chris W.

Reputation: 23280

Insert anchor link in :after selector content

So I'm just trying to insert a link after some content but it just displays the literal string. How do I change this?

<p>Blah Blah Blah I'm some content</p>

CSS:

p:after {
    content: '- <a href="http://www.stackoverflow.com">Learn More</a>'
}

which produces of course the text:

<!-- language: lang-none -->

Blah Blah Blah I'm some content - <a href="http://www.stackoverflow.com">Learn More</a>

I expect the following output

Blah Blah Blah I'm some content - Learn More

Upvotes: 2

Views: 2243

Answers (1)

G-Cyrillus
G-Cyrillus

Reputation: 105883

You need javaScript for this kind of things.

It can easily be done with jQuery. DEMO

HTML

<p id="p">Blah Blah Blah I'm some content</p>

jQuery

var plink ='- <a href="http://www.stackoverflow.com">Learn More</a>';
$('#p').append(plink);

Upvotes: 1

Related Questions