加载内容后隐藏 cshtml 中的行

Hiding the row in the cshtml after the contents are loaded

我的 cshtml 中有两行显示金额值。我需要实施的业务规则是,如果两个金额相等,则只需要显示一行。我已经编写了代码,但不确定如何让它工作。

$(function ShowHideRow () {

            var cashAvailbleToInvestInFunds = $('#trCashAvailableToInvestInFunds').val;
            var cashAvailbleToInvestInEquities = $('#trCashAvailableToInvestInEquities').val;

            if (cashAvailbleToInvestInFunds == cashAvailbleToInvestInEquities)
                $('#trCashAvailableToInvestInEquities').hide();
        });


<tr id="trCashAvailableToInvestInFunds" >
                        <td>Available cash to Invest in funds at @date_request</td>
                        <td>@Model.CashAvailableToInvest.ToString("C")</td>
                    </tr>
                    <tr id="trCashAvailableToInvestInEquities">
                        <td>Available cash to Invest in equities at @date_request</td>
                        <td>@Model.CashAvailableToInvestInEquities.ToString("C")</td>
                    </tr>

我尝试在 DocumentReady 上编写逻辑,但那行不通,因为该函数甚至在内容加载之前就会触发。谁能告诉我该怎么做。

我会在 Razor 视图中执行此操作:

    <tr id="trCashAvailableToInvestInFunds" >
                        <td>Available cash to Invest in funds at @date_request</td>
                        <td>@Model.CashAvailableToInvest.ToString("C")</td>
                    </tr>
@if(Model.CashAvailableToInvestInEquities != Model.CashAvailableToInvest)
{
                    <tr id="trCashAvailableToInvestInEquities">
                        <td>Available cash to Invest in equities at @date_request</td>
                        <td>@Model.CashAvailableToInvestInEquities.ToString("C")</td>
                    </tr>
}