首页 > 解决方案 > 背景颜色未应用于按钮

问题描述

我正在使用 XML 和 XSLT 并将其转换为 HTML。并将 html 内容传递给 javascript 函数。但问题是样式类被调用并且线通和下划线被应用但不是背景颜色,我也使用了!重要的仍然没有应用背景颜色。谁可以帮我这个事。

My function

 $(function () {
            
            $("#Button1").click(function () {
                
                $('#displayCompare2').addClass('ins','del');
                var original = document.getElementById("displayCompare").innerHTML;
                var changed = document.getElementById("displayCompare2").innerHTML;

                let output = htmldiff(original, changed);
                
                document.getElementById("displayCompare2").innerHTML = output;
            })
        })


我的风格课

     .ins {
        text-decoration: none;
        background-color: #d4fcbc;
      }

    .del {
        
        text-decoration: line-through;          
        background-color: #fbb6c2 ;

    }

我的 XSLT

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
  <xsl:template match="/">
    <html>

      <body >
        <xsl:for-each select="table/tr">
          <div style="padding:4px">

            <span style="font-weight:bold;">
              <xsl:value-of select="td1"/>
            </span>

          </div>
          <div style="padding:4px" >
            <xsl:if test="not(contains(td2, '|'))">
              <xsl:value-of select="td2"/>
            </xsl:if>
            <xsl:if test="contains(td2, '|')">

              <xsl:value-of select="substring-after(td2, '|')"/>

            </xsl:if>
          </div>
        </xsl:for-each>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

标签: javascriptjqueryxslt

解决方案


推荐阅读