如何创建if语句来处理html中的空字符串

How to create if statement to handle a empty string in html

本文关键字:html 处理 字符串 语句 何创建 创建 if      更新时间:2023-09-26

我想创建一个情况说别的东西,如果我的字符串是空的,我怎么能做到这一点?

<div class="padding" id="dealBorder">
    <pre id="informationDealText"><pan class="inner-pre" style="font-size: 24px; color: white;" ><font face="times new roman">{{data.$value}}</font></span></pre>
</div>

您正在寻找使用ng-if -非常简单的使用-它计算您传递的语句是否为真,并相应地呈现元素。

 <style>
     .inline-styles-are-bad {
       color: 'white';
       font-size: 22px;
     }
     .font-tags-are-worse {
       font-family: 'times new roman', serif; /* bless your users */
     }
 </style>
<pre id="#someID">
 <span class="inline-styles-are-bad font-tags-are-worse" ng-if="data.value.length > 0">{{data.value}}</span>
 <span ng-if="data.value.length == 0">Something else</span>
</pre>

我不确定这是否是你想要的。我还没有执行这段代码,所以请尝试一下。

<div class="padding" id="dealBorder">
    <pre id="informationDealText"><pan class="inner-pre" style="font-size: 24px; color: white;" ><font face="times new roman">{{data.$value}}</font></span></pre>
</div>
<script>
    if({{data.$value}} = "" || {{data.$value}} = null){
        $('#informationDealText').text("string empty!");
    }
</script>