1

我应用以下脚本为我在应用程序 (JIRA) 中添加的评论添加颜色。

<script type="text/javascript">
$(document).ready(function() {
    $(".activity-comment:even").css("background-color","#6699FF"); 
    $(".activity-comment:odd").css("background-color","#B2CCFF"); 
});

评论 http://i.minus.com/jFoE7kcaTqdrp.JPG

应用脚本后,评论显示如上,但是当我移动到其他选项卡(即工作日志、历史记录)或添加新评论时,脚本不起作用。我需要刷新页面才能执行脚本。

有人可以帮我如何永久设置颜色吗?

注意:我在应用程序公告横幅上应用了 javascript,这使得脚本在应用程序的每个页面上运行,我可以对源文件进行更改。

提前致谢 :)

4

1 回答 1

1

我认为您可以通过两种方式实现这一目标:

1- 通过使用 CSS:在您的 css 文件中,只需添加以下代码行:

.activity-comment:even{
    background-color: #6699FF;
}
.activity-comment:odd{
    background-color: #B2CCFF;
}

2- 通过 Jquery:在这种情况下,使用jquery 的.live()函数来实现动态添加评论的样式。比如获取评论提交按钮的id(假设:comment_add),然后:

$("#comment_add").live('click',function(){
    $(".activity-comment:even").css("background-color","#6699FF"); 
    $(".activity-comment:odd").css("background-color","#B2CCFF");
});

我想它会对你有所帮助。

于 2013-01-18T07:02:17.623 回答