如何在jqueryshow中插入Php
你好,我正在插入如何在jqueryshow中插入Php,php,jquery,wordpress,Php,Jquery,Wordpress,你好,我正在插入 <?php comments_template(); ?> 进入下面的jqueryshow函数,但它不起作用。甚至可以将php函数插入jQuery吗? *更新 <head> <script src="code.jquery.com/jquery-latest.js"></script>; </head> <button>Show it</button> <a style="d
<?php comments_template(); ?>
进入下面的jqueryshow函数,但它不起作用。甚至可以将php函数插入jQuery吗?
*更新
<head>
<script src="code.jquery.com/jquery-latest.js"></script>;
</head>
<button>Show it</button>
<a style="display: none"><?php comments_template(); ?></a>
<script>
$("button").click(function () { $("a").show("slow"); });
</script>
;
表现出来
$(“按钮”)。单击(函数(){$().show(“slow”);});
如果您的注释模板以字符串形式返回其结果,而不是直接使用echo打印,则可能需要如下内容:
<?php echo comments_template(); ?>
<div class="comment-1 collapse">
<?php echo comments_template(); ?>
</div>
<button data-target=".comment-1" data-toggle="collapse">Show Comment</button>
首先,让您的
注释\u模板()返回完整字符串
然后,尝试这样构造代码。您希望.hide()
在.ready()
上隐藏注释,然后在单击.comment按钮时显示注释
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<button class="comment-button">Show Comments</button>
<p class="comments"><?php echo comments_template(); ?></p>
<script>
$("document").ready(function() {
$(".comments").hide();
$(".comment-button").click(function () {
$(".comments").show("slow");
});
});
</script>
</body>
不需要Javascript,因为它已经在引导库中。请告诉我们您是如何插入它的。您想在哪里插入它?我什么也没看到你还没合上头牌。另外,您需要显示HTML,然后在$(“文档”).ready()
上显示它。ready()
我刚刚像这样插入了它…head>感谢您的回复,但仍然没有骰子这里有一个链接(NSFW)。您知道,您可以为测试页面选择更好的链接。而且,您隐藏了错误的元素。使用类。我为刚才删除的图像道歉。。。。。使用类是什么意思?