开发者

hide span class on visited link

I want to display a span class along with the link, for example

<a href="#">New entries<span class="number">1</span></a>

But as th开发者_开发百科e link is visited, i want to remove the span class from the link, and only want to display:

<a href="#">New entries</a>

How can I do this by any simple approach? Thanks.


With JavaScript try adding a click event to the A element, finding the SPAN element from it's children and then destroying it - like (pseudo-jQuery):

$("A").click(function (e) {
    var span = $(this).children("SPAN");
    if (span.length < 1) { return; }
    span[0].remove()
});

With pure CSS, you could simply do:

A:visited SPAN { display: none; }


Use this code, it works perfectly:

<html>
    <head>
        <style type="text/css">
            a:hover span { display: none; }
        </style>
    </head>
    <body>
        <a href="#">New entries<span class="number">1</span></a>
    </body>
</html>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜