3

我想用 php 在我的 html (.complete) 中添加一个类:

if( get_field('to-do-repeater') )
{
    Add (complete) class to <div class="to-do to-do-wrap"> should be <div class="to-do to-do-wrap complete">
}
else
{
    Do nothing
}
4

2 回答 2

7

试试这个代码:

<div class="to-do to-do-wrap<?php echo get_field('to-do-repeater') ? ' complete' : '' ?>"></div>
于 2012-08-07T19:11:28.530 回答
3
<?php

echo "<div class=\"to-do to-do-wrap ";
if(get_field('to-do-repeater'))
{
    echo "complete";
}
echo " \"></div>";

?>
于 2012-08-07T19:09:56.177 回答