使用javascript或jquery设置a:访问样式 [英] set a:visited style with javascript or jquery

查看:103
本文介绍了使用javascript或jquery设置a:访问样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何设置一个样式:访问与javascript或jquery。我知道如何使用常规链接设置

  document.getElementById('a12')。style.color ='#ff0000 '; 

但我不知道如何使用a:visited?

解决方案

样式属性调整适用于元素的样式属性,它们完全替代选择器

您有两个选择。




  • 事先编写规则集,然后设计

     <$> 

    c $ c> .foo:visited {
    color:#f00;
    }

    document.getElementById('a12')。className + ='foo';




    • 使用与元素匹配的选择器动态生成规则集。 li>


    请参阅bobince的回答从JavaScript设置CSS伪类规则


    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.color = '#ff0000';
    

    But I don't know how it work with a:visited?

    解决方案

    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

    这篇关于使用javascript或jquery设置a:访问样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆