我正在尝试根据按下的按钮来显示和隐藏内容。下一个按钮应该显示第二个内容并隐藏第一个内容,而上一个按钮则相反。
<script type="text/javascript">
$('a.button-next').click(function() {
$("#tab-content2").addClass("show");
});
</script>
CSS:
#tab-content2 {
display: none;
}
#tab-content2.show {
display: none;
}
HTML:
<div id="tab-content1">
<?php the_content(); ?>
</div>
<div id="tab-content2">
<?php the_field("experience");?>
</div>
<a href="javascript:;" class="button-back">Previous</a>
<a href="javascript:;" class="button-next">next</a>
$("#tab-content2").toggle()
,这样你甚至不需要 CSS。 - Aleksandar Toplekdisplay: none;
。此外,在你的jQuery代码中没有文档准备好的处理程序。 - Rory McCrossan.show()
和.hide()
方法... - JJJ