【问题标题】:How to hide a column in jquery template如何在 jquery 模板中隐藏一列
【发布时间】:2018-10-28 14:03:15
【问题描述】:

我正在使用 jquery 模板来填充订单详细信息。我有一个隐藏字段,根据它的值,我需要隐藏或显示一个特定的列。怎么做。我的代码如下所示

<script id="TestTemplate" type="text/x-jquery-tmpl">        
        <tr id="trOrderDetail">
             <td align="right">${order_id}</td>      
            {{ if document.getElementById('hdnShowQty').value == "0" }}
             <td align="right">${qty}</td>
            {{/if}} 
        </tr>
    </script>

我试过了,但它不起作用。

【问题讨论】:

    标签: jquery dom jquery-templates


    【解决方案1】:

    我得到了代码工作。 {{ 和 if , }} 和 "0" 之间有空格。所以正确的代码如下

    <script id="TestTemplate" type="text/x-jquery-tmpl">        
            <tr id="trOrderDetail">
                 <td align="right">${order_id}</td>      
                {{if document.getElementById('hdnShowQty').value == "0"}}
                 <td align="right">${qty}</td>
                {{/if}} 
            </tr>
        </script>
    

    【讨论】:

      猜你喜欢
      • 2013-03-05
      • 2012-11-14
      • 1970-01-01
      • 1970-01-01
      • 2021-07-28
      • 2017-01-30
      • 1970-01-01
      • 1970-01-01
      • 2020-05-21
      相关资源
      最近更新 更多