我如何做到这一点,以便一键打开div就可以添加课程,而关闭它则可以删除课程?我使用readmore js库,并在要指定的回调函数中使用。 HTML:
<div class="around-about-us">
<span class="contact-header"><?php _e('About us', 'slotsfans') ?></span>
<div class="text toggle-text toggle-over">
more text
</div>
</div>
CSS:
.toggle-over {
overflow: hidden;
}
.toogle-height {
height: 100% !important;
}
JS:
jQuery(document).ready(function ($) {
$('.toggle-text').readmore({
moreLink: '<a href="#" class="show_after"><p class="pattern-btn-underline read_more_btn">Read more</p></a>',
lessLink: '<a href="#" class="show_after"><p class="pattern-btn-underline read_more_btn">test</p></a>',
collapsedHeight: 534,
speed: 1500,
beforeToggle: function () {
$(".toggle-text").removeClass("toggle-over").addClass('toogle-height');
}
});
});
答案 0 :(得分:1)
如评论中的jonathan hamel所示
尝试-
$(".toggle-text").toggleClass("toggle-over")
$(".toggle-text").toggleClass("toggle-height")