Detect if a link has been clicked and apply a different CSS class if it has

前端 未结 5 1868
轻奢々
轻奢々 2021-01-14 12:53

So what I want to do is determine if the current link is \'active\', i.e. if this link was just clicked by the user.

If it is, then I want to apply the class=s

5条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-14 13:35

    I believe you want the :focus pseudo-class.

    a:focus {
        background-color : #000;
        color            : #fff;
    }
    

    Here's a jsfiddle: http://jsfiddle.net/jasper/xn7UW/

提交回复
热议问题