Skip to content

Instantly share code, notes, and snippets.

@imranhoshain
Created January 15, 2022 07:03
Show Gist options
  • Save imranhoshain/06268acd25b0090cdb29ecf5be123d12 to your computer and use it in GitHub Desktop.
Save imranhoshain/06268acd25b0090cdb29ecf5be123d12 to your computer and use it in GitHub Desktop.
<style>
.totalpoll-question-content {
margin-bottom: 1em;
margin-left: 0px !important;
}
.totalpoll-question-choices label {
display: none;
}
a.loadMore, a.loadLess {
border: 1px solid #e0e0e0 !important;
padding: 10px 20px !important;
position: absolute;
bottom: 20px;
margin-left: 8px !important;
}
a.loadMore:hover, a.loadLess:hover {
background: #8e6e53 !important;
color: #fff !important;
}
</style>
<script>
jQuery(document).ready(function () {
jQuery('div.totalpoll-question-choices').each(function () {
if (jQuery(this).children('label').length > 3) {
jQuery(this).children('label:lt(3)').show();
jQuery(this).append('<a class="loadMore">Load More</a>');
}
});
jQuery('div.totalpoll-question-choices').on("click", '.loadMore', function () {
jQuery(this).parent('.totalpoll-question-choices').children('label').show(); // use gt instead of lt
jQuery(this).removeClass('loadMore').addClass('loadLess').text('Load Less');
});
jQuery('div.totalpoll-question-choices').on("click", '.loadLess', function () {
jQuery(this).parent('.totalpoll-question-choices').children('label:gt(3)').hide(); // use gt instead of lt
jQuery(this).removeClass('loadLess').addClass('loadMore').text('Load More');
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment