PHP add class to html div

前端 未结 2 547
时光说笑
时光说笑 2021-01-14 09:49

i would like to add a class to my html (.complete) with php:

if( get_field(\'to-do-repeater\') )
{
    Add (complete) class to 
相关标签:
2条回答
  • 2021-01-14 09:54
    <?php
    
    echo "<div class=\"to-do to-do-wrap ";
    if(get_field('to-do-repeater'))
    {
        echo "complete";
    }
    echo " \"></div>";
    
    ?>
    
    0 讨论(0)
  • 2021-01-14 09:57

    Try this code :

    <div class="to-do to-do-wrap<?php echo get_field('to-do-repeater') ? ' complete' : '' ?>"></div>
    
    0 讨论(0)
提交回复
热议问题