【问题标题】:Changing background color of the row on click of a link单击链接时更改行的背景颜色
【发布时间】:2011-10-20 16:32:19
【问题描述】:

我正在使用 Richfaces 4。我有一个有 4 列的 <rich:datatable />。其中,第一列是 <a4j:commandlink /> 。单击链接时,我需要更改整行的背景颜色。单击链接时,我正在调用动作侦听器,oncomplete 我正在重新呈现页面。如何更改点击行的颜色?

【问题讨论】:

    标签: jsf-2 richfaces richdatatable


    【解决方案1】:

    在您的链接上添加 onclick 方法:

    <rich:column>
      <a4j:commandlink onclick="changeBackground(this)" ...
    </rich:column>
    

    查找单元格的 tr 并应用样式的脚本(使用 jQuery):

    <script>
        function changeBackground(element){
          jQuery(element).parents('tr:first').addClass('backgroundRed');
        }
    </script>
    

    以 css 为例

    .backgroundRed {
        color: #555658;
        background-color: red;
    }
    

    您可以查看this conversation以获取更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-12
      • 2019-09-01
      • 2014-06-12
      • 2011-06-05
      • 2014-10-09
      • 2013-09-27
      • 2017-08-02
      相关资源
      最近更新 更多