dongtang3155 2018-06-08 08:55
浏览 745
已采纳

我想根据条件更改文本颜色

I am trying to show the text color change dynamically based on the condition that i am using in the code.Below is the code that i am using.Please help me out from this problem.

<span class="pendtext" style="font-size:15px;">{{($duepay->status == 'issued') ? 'PENDING' : (($duepay->status == 'paid') ? 'SUCCESSFUL' : $duepay->status)}}</span>


<script>

if($duepay->status == 'issued'){
  $(".pendtext").css('color','green');
}
else{
  $(".pendtext").css('color','yellow');
}

</script>
  • 写回答

3条回答 默认 最新

  • doushan1850 2018-06-08 09:03
    关注

    Why use a JS if you work with PHP? you can do with PHP too like

    <span class="pendtext" style="font-size:15px;color:{{($duepay->status == 'issued')?'green':'yellow'}}">{{($duepay->status == 'issued') ? 'PENDING' : (($duepay->status == 'paid') ? 'SUCCESSFUL' : $duepay->status)}}</span>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services