PHP向html div添加类

标签 php addclass

我想使用 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
}

最佳答案

试试这个代码:

<div class="to-do to-do-wrap<?php echo get_field('to-do-repeater') ? ' complete' : '' ?>"></div>

关于PHP向html div添加类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11852425/

相关文章:

javascript - 我如何选择具有特定类的 div ID,然后使用 jQuery/javascript 将该类移动到下一个 ID?

php - 求和并显示总分

php - 添加 DocType 以退出 DOMDocument

jQuery 基于 paren 数据属性添加类

jquery - 有没有办法缩短这个 jquery 代码?

javascript - 如何使用 jQuery 为一个兄弟元素的所有父元素添加类

php - 如果使用 AJax 数据库中存在值,则表单自动填充

php - Wordpress 自定义主题中的 Bootstrap 3 响应式表格代码替换

php - Symfony2 : Error with entitymanager configuration

jquery .find 或 .closest then addclass 在 IE 或 Chrome 中不起作用