我正在尝试在Shopify商店的收藏描述中添加“阅读更多”和“阅读更少”按钮,如何添加液体状态的HTML?目前,{{ collection.description }}是collection.description模板中的唯一内容。HTML在店面上运行良好,但如何添加液体对象的HTML?
...
<p>text before Read More<span id="dots">...</span><span id="more"> the remaining
description</span></p>
<button id="myBtn" onclick="myFunction()">Read more</button>
<script>
function myFunction() {
var dots = document.getElementById("dots");
var moreText = document.getElementById("more");
var btnText = document.getElementById("myBtn");
if (dots.style.display === "none") {
dots.style.display = "inline";
btnText.innerHTML = "Read more";
moreText.style.display = "none";
} else {
dots.style.display = "none";
btnText.innerHTML = "Read less";
moreText.style.display = "inline";
}
}
</script>
...
1条答案
按热度按时间bihw5rsg1#