加载后更改字体颜色

时间:2012-07-05 11:04:45

标签: javascript jquery css

是否可以更改下面“查看结果”文字的颜色?

   <script type="text/javascript" charset="utf-8" src="http://static.polldaddy.com/p/6352993.js"></script>
    <noscript><a href="http://polldaddy.com/poll/6352993/">This is very long test question to test how polldaddy handles questions that exceed that normal length............ yes a very long question indeed..............</a></noscript>​

我已经尝试重写css'pds-view-results',这就是“查看结果”的样式但没有效果:

.pds-view-results {
    color: red;
}

这是一个小提琴:

http://jsfiddle.net/25LjE/36/

3 个答案:

答案 0 :(得分:5)

由于规则已指定了链接颜色,因此您应通过!important关键字

覆盖它
.pds-view-results {
    color: red !important;
}

答案 1 :(得分:1)

您可以通过javascript执行此操作:

$('.pds-view-results').css('color', 'red');

答案 2 :(得分:1)

您还可以设置style

这样您可以避免!importantjavascript。但是,我建议你只放这样的最后一条css规则,因为它可能会导致闪烁。试试吧,它可能适合你。

<script type="text/javascript" charset="utf-8" src="http://static.polldaddy.com/p/6352993.js"></script>
<noscript><a href="http://polldaddy.com/poll/6352993/">This is very long test question to test how polldaddy handles questions that exceed that normal length............ yes a very long question indeed..............</a></noscript>

<style type='text/css'>
    .pds-pd-link {
display: none !important;
}
.pds-box {
    width: 220px !important;
}
.pds-input-label{
    width: auto! important;
}
.PDS_Poll{
    margin-bottom:15px;
}
.pds-view-results {
    color: red;
}
#PDI_container6352993 .pds-links a{
  color:blue;
}
</style>​

http://jsfiddle.net/nXS4J/