Set a:visited style with JavaScript or jQuery

前端 未结 1 1611
误落风尘
误落风尘 2020-12-12 03:11

How I can set a style of a:visited with JavaScript or jQuery. I know how to set with a regular link like

document.getElementById(\'a12\').style.c         


        
相关标签:
1条回答
  • 2020-12-12 03:41

    Style properties adjust style attributes which apply to elements, they completely replace selectors

    You have two choices.

    • Write your rule-sets in advance, and then design the element to match the selector.

    e.g.

    .foo:visited {
      color: #f00;
    }
    
    document.getElementById('a12').className += ' foo';
    
    • Dynamically generate rule-sets with selectors that match the element.

    See bobince's answer at Setting CSS pseudo-class rules from JavaScript

    0 讨论(0)
提交回复
热议问题