当前位置: 动力学知识库 > 问答 > 编程问答 >

html - how do you decorate a visited link?

问题描述:

Why isn't text-decoration: line-through; working on a visited link? When I click the link it only seems to change the color of the text but ignores text-decoration..

code:

<a href="https://www.youtube.com">youtube</a>

<style>

a:link {

color:#666;

text-decoration:none;

}

a:visited {

cursor: pointer;

color: #F00;

text-decoration: line-through;

}

</style>

I want to be able to do this with my links example. Right when you click 'watch this link' it changes and puts a red line through.

网友答案:

You are unable to style visited links in this way by design.

See this post

The site you have referenced has used javascript and jquery (not very well) to add the styling:

onclick="$(this).css('color','#AE3939'); $(this).css('text-decoration','line-through');"

You will see if you refresh the page after clicking the link it won't keep the styling so therefore isn't styling :visited as you are describing

网友答案:

I visited the link you posted. It works perfectly for me. Using Google Chrome.

分享给朋友:
您可能感兴趣的文章:
随机阅读: