jquery highlight the link when clicked

后端 未结 7 1688
梦毁少年i
梦毁少年i 2021-01-14 22:41

How do I use jquery to highlight the link when I click on it?

For example, when I click on the link class1_1, I want to make this link red (or another color).

<
7条回答
  •  天涯浪人
    2021-01-14 23:18

    It's possible using CSS, no jQuery required:

    Highlight:

    a:active {
        background-color: #FF0000;
    }
    

    Change link color:

    a:active {
        color: #FF0000;
    }
    

    Edit: Responding to your comment... If your links are not directing the browser to another page, you can use Mike Robinson's answer to accomplish the same effect without leaving the page and without changing the color back to default onblur.

提交回复
热议问题