Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
563 views
in Technique[技术] by (71.8m points)

刷新网页恢复超链接颜色

类似这个问题
https://ostack.cn/q/10...

设置超链接颜色默认blue,移动到超链接上显示red,点击后显示fuchsia
因为网页存在cookie而刷新后超链接颜色不能重置,现用jquery模拟,希望刷新网页恢复超链接颜色

想要用jquery模仿超链接hover事件,但是fuchsia紫色出不来..
也试过其它比如mouseup,mouseleave一头雾水..

<script>

$('a').css('color','blue');

$('a').mouseover(function(){ 
    $(this).css('color','red');
}).mouseout(function(){ 
    $(this).css('color','blue');
}).click(function(){ 
    $(this).css('color','fuchsia');
});

</script>


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

这样呢?

$('a').css('color','blue');

$('a').mouseover(function(){ 
    $(this).data("visited") || $(this).css('color','red');
}).mouseout(function(){ 
    $(this).data("visited") || $(this).css('color','blue');
}).click(function(){ 
    $(this).data("visited", true).css('color','fuchsia');
})

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...