为了使该功能将显示更改为“隐藏”然后返回“阻止”,每次需要单击 2 次。为什么是这样?如何将其减少到只需一键点击?
function showOfferMessage() {
var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.display === "block") {
content.style.display = "none";
} else {
content.style.display = "block";
}
});
}
}
<div class="offer-row collapsible" id="'.$oid.'" onclick="showOfferMessage()">
<div class="offer-info-item">
<div class="offcatreview-title">
<h3>Cat. Rating</h3>
</div>
<div class="offer-cat-rating">
</div>
</div>
</div>
<div class="content">
<p>'.$message.'</p>
</div>
一只甜甜圈
白衣非少年
HUWWW
相关分类