gpt4 book ai didi

javascript - 单击时辅助列移动+三个点不应该是元素符号

转载 作者:行者123 更新时间:2023-11-28 19:17:11 25 4
gpt4 key购买 nike

我想弄清楚如何让 3 个点不是子弹。我也不想隐藏元素符号,因为它会在我的元素符号列表中显示为空白,就像您单击“显示更多”按钮并使列表不均匀时一样。我不太了解 JavaScript,所以我不确定如何解决这个问题。

 <head>
<script>
function myFunction() {
var dots = document.getElementById("dots");
var btnText = document.getElementById("myBtn");
var more = document.querySelectorAll(".more");

if (dots.style.display === "none") {
more.forEach(el => el.classList.add("hidden"));
dots.style.display = "inline";
btnText.innerHTML = "Read more";
} else {
more.forEach(el => el.classList.remove("hidden"));
dots.style.display = "none";
btnText.innerHTML = "Read less";
}
}
</script>
<style>
#more {
display: none;
}

.columns {
columns: 2;
-webkit-columns: 2;
-moz-columns: 2;
position: relative;
}

.hed {
font-size: 16px;
font-weight: 800;
list-style: none;
margin: 15px 0px 5px;
}

.hidden {
display: none;
}

table.map-list td{
width:50% !important;
vertical-align: top !important;
}

</style>

</head>

<body>

<table class="map-list" width="100%" border="0">
<tbody>
<tr>
<td>
<h4>Elementary</h4>
<ul>
<li>Maps: Primary: ELS</li>
<li>Maps: Primary: Readiness</li>
<li><span id="dots">...</span></li>
<li class="more hidden">U.S. History:8 Revolutionary
War</li>
</ul>
</td>

<td>
<h4>Secondary</h4>
<ul>
<li>Maps: Intermediate: Physical</li>
<li>Maps: Intermediate: Political</li>
<li class="more hidden">Maps: Secondary: Population
Thematic</li>

</ul>
</td>
</tr>
</tbody>
</table>
<button onclick="myFunction()" id="myBtn">Read more</button>
</body>

最佳答案

删除父级 <li> dots 的元素span 会解决这个问题。

<span id="dots">...</span>

实例:

<head>
<script>
function myFunction() {
var dots = document.getElementById("dots");
var btnText = document.getElementById("myBtn");
var more = document.querySelectorAll(".more");

if (dots.style.display === "none") {
more.forEach(el => el.classList.add("hidden"));
dots.style.display = "inline";
btnText.innerHTML = "Read more";
} else {
more.forEach(el => el.classList.remove("hidden"));
dots.style.display = "none";
btnText.innerHTML = "Read less";
}
}
</script>
<style>
#more {
display: none;
}

.columns {
columns: 2;
-webkit-columns: 2;
-moz-columns: 2;
position: relative;
}

.hed {
font-size: 16px;
font-weight: 800;
list-style: none;
margin: 15px 0px 5px;
}

.hidden {
display: none;
}

table.map-list td{
width:50% !important;
vertical-align: top !important;
}

</style>

</head>

<body>

<table class="map-list" width="100%" border="0">
<tbody>
<tr>
<td>
<h4>Elementary</h4>
<ul>
<li>Maps: Primary: ELS</li>
<li>Maps: Primary: Readiness</li>
<span id="dots">...</span>
<li class="more hidden">U.S. History:8 Revolutionary
War</li>
</ul>
</td>

<td>
<h4>Secondary</h4>
<ul>
<li>Maps: Intermediate: Physical</li>
<li>Maps: Intermediate: Political</li>
<li class="more hidden">Maps: Secondary: Population
Thematic</li>

</ul>
</td>
</tr>
</tbody>
</table>
<button onclick="myFunction()" id="myBtn">Read more</button>
</body>

关于javascript - 单击时辅助列移动+三个点不应该是元素符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58067765/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com