我想在索引上显示我的参考作品。我限制了单词。我的目标是:想要了解有关帖子的详细信息的用户,将单击帖子缩略图,其余内容将以弹出窗口打开。
我使用 w3css modal 来制作它。我的javascript代码是:
// Get the modal
var modal = document.getElementById('myModal');
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks on the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
但只有第一篇文章似乎是这样的。其他人没有任何反应。
谢谢。
我对此做了一些修改。我使用了 fancybox 2 并用这个更改了我的代码
<a href="#inline1" rel="gallery" class="fancybox"><?php the_post_thumbnail('thumbnail', array('class' => 'aligncenter')); ?></a>
<div id="inline1" style="width:400px;display: none;">
<?php the_post_thumbnail('thumbnail', array('class' => 'aligncenter')); ?><?php the_content(); ?>
</div>
现在所有缩略图都用fancybox打开了,但这次其他缩略图的内容与第一篇文章相同。