我创建了一个我想坐在SharePoint中的代码,当我在SharePoint之外测试该代码时,它不会刷新。一旦我在SharePoint中试用了代码,在单击手风琴后它将刷新。我对编码非常陌生,可以让我知道我错过了什么吗?
var acc = document.getElementsByClassName("accordion");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.maxHeight){
panel.style.maxHeight = null;
} else {
panel.style.maxHeight = panel.scrollHeight + "px";
}
});
}
.accordion {
cursor: pointer;
padding: 5px;
width: 100%;
border: none;
outline: none;
}
.active, .accordion:hover {
background-color:#f5f3f3 ;
}
.accordion:after {
content: '\002B';
color: none;
font-weight: bold;
float: left;
}
.active:after {
content: "\2212";
}
.panel {
padding: 2px;
background-color: white;
max-height: 0;
overflow: hidden;
margin-left: 22px;
}
<button class="accordion"> <b>XXXXX</b></button>
<div class="panel">
<p Style="font-family:Arial; font-size:13px">XXXXX</p>
</div>