【发布时间】:2013-07-09 12:42:38
【问题描述】:
请帮帮我:
我的页面顶部有四个缩略图,当点击它们时,帖子的内容会向下切换。问题是它们相互堆叠。
我需要它们一次显示一个。单击一个时,它会向下切换,单击另一个时,“活动”的一个会滑开并出现单击的那个。
代码如下:
<script type="text/javascript">
function toggleDiv(divId) {
$("#"+divId).slideToggle('hidden');
}
</script>
HTML
<div id="news-bar">
<?php query_posts('cat=10'); ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<ul class="news-feed">
<li>
<a class="shadow" href="javascript:toggleDiv('post-<?php the_ID(); ?>');">
<?php
if ( has_post_thumbnail() ) {
// the current post has a thumbnail
the_post_thumbnail();
echo '<div class="image-caption">' .get_post(get_post_thumbnail_id())->post_excerpt. '</div>';
} else {
// the current post lacks a thumbnail
}
?>
</a>
</li>
</ul>
<div class="myContent" id="post-<?php the_ID(); ?>">
<h2><a href="<?php // the_permalink(); ?>"> <?php // the_title(); ?></a></h2>
<p><?php the_content(); ?></p>
</div>
<?php endwhile; ?> <?php wp_reset_query(); ?>
</div> >
【问题讨论】: