Skip to content

Instantly share code, notes, and snippets.

@andronex
Created March 30, 2017 12:24
Show Gist options
  • Save andronex/11055d4e2daa2fd06e66c0023a6f6c0c to your computer and use it in GitHub Desktop.
Save andronex/11055d4e2daa2fd06e66c0023a6f6c0c to your computer and use it in GitHub Desktop.
Сокрытие части контента и отображение при клике на кнопку
<!--noindex-->
<p id="texthidecomments" style="text-align:center;font-style:italic">----- некоторые вопросы были скрыты -----</p>
<h4 id="showallcomments" style="display: block;">
<a href="[[*uri]]#" class="wpb_button_anone"><span class="wpb_none btn btn-default">Показать все вопросы</span></a>
</h4>
<!--/noindex-->
<script>
jQuery( document ).ready(function() {
var $div = jQuery("li[data-parent=0]");
var start = 7;
var end = $div.length;
if ( end === $div.length ) {
end = undefined;
}
$div.css( "display", "block" );
if ( end ) {
$div.slice( start, end ).css( "display", "none" );
} else {
$div.slice( start ).css( "display", "none" );
}
jQuery( "#showallcomments a" ).on( "click", function() {
jQuery('#showallcomments, #texthidecomments').hide();
if ( end ) {
$div.slice( start, end ).css( "display", "block" );
} else {
$div.slice( start ).css( "display", "block" );
}
return false;
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment