php - Jquery 在 Div 内添加按钮

标签 php jquery

我有这个代码块:

<div class="services">
    <div class="grid grid-pad">

        <?php
        query_posts(array('post_type' => 'services', 'posts_per_page' => -1));

        while (have_posts()) : the_post();
            ?> 

            <div class="col-1-3 tri-clear">
                <div class="single-service">
                    <i class="fa <?php echo types_render_field("icon", array("output" => "raw")); ?> service-icon"></i>
                    <?php the_title('<h3 class="service-title">', '</h3>'); ?>
                    <?php the_content('<p>', '</p>'); ?>
                </div>
            </div>

        <?php endwhile; ?> 

        <!-- how to add button here? -->

    </div> 
</div>

我要添加<button>Contact Us</button>那里(我标记的地方)。由于某种原因,我无法编辑源代码,但我可以添加自定义 javascript(使用 jQuery)来添加按钮。如何实现?

感谢您的建议。

最佳答案

试试这个代码:

jQuery('.services .grid.grid-pad').append('<button>Contact us</button>');

关于php - Jquery 在 Div 内添加按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38069414/

相关文章:

php - 使用 Malsup 的 jQuery 文件上传进度条在 PHP 中上传失败

php - PHP 中的内存缓存

php - 如何使用 phpspec 测试异常处理程序

javascript - 自定义弹出谷歌地图

javascript - 列出jquery select的所有函数

javascript - hashchange 事件未在简单 spa 中使用 jquery 触发

php - '1' 数字出现在 wordpress 网站的侧边栏下

php - 用于 HTML5 的轻量级 PHP/MySQL CMS

javascript - 如何在 JavaScript 中检索元属性 og 的内容?

javascript - jQuery AJAX : why is . error() 方法已弃用,取而代之的是 .fail()?