如何实现展开和收齐,展开的代码如下

<div class="text"><div class="fullhint">{{hint:完全展开}}</div></div></br><div class='from'>

 

<script>

// remove cloze syntax from revealed hint

var hint = document.querySelector('.fullhint>[id^="hint"]')

var html = hint.innerHTML.replace(/\[\[oc(\d+)::(.*?)(::(.*?))?\]\]/mg, "$2")

hint.innerHTML = html

// scroll to cloze

document.addEventListener('DOMContentLoaded', function() {

setTimeout(function(){

const cloze1 = document.getElementsByClassName("cloze")[0];

const rect = cloze1.getBoundingClientRect();

const absTop = rect.top + window.pageYOffset;

const absBot = rect.bottom + window.pageYOffset;

if (absBot >= window.innerHeight) {

const height = rect.top - rect.bottom

const middle = absTop - (window.innerHeight/2) - (height/2);

window.scrollTo(0, middle);};

}, 1);

}, false);

 

</script>