gpt4 book ai didi

javascript - 如何修复简单的 Javascript 下拉错误?

转载 作者:行者123 更新时间:2023-11-28 16:56:16 24 4
gpt4 key购买 nike

我在使用此下拉菜单时遇到问题,我正在为客户编辑代码,并将下拉菜单组从 7 个减少到 3 个,这是我的 code

我想要做的是激活第三个下拉菜单并添加 css,以便在下拉时圆边消失

我知道这与这里的脚本有关:

function toggleGroup(group){
var isShown = document.getElementById("group"+group).style.display;


if (!isShown || isShown=="none"){

for (i = 1; i < 4; i++) {

if (i != group){
document.getElementById("group"+i).style.display="none";
document.getElementById("toggle"+i).src ="img/moreIcon.png";
location.hash = "#myAnchor";
if(i=="3"){
document.getElementById("backgroundSpeech").style.borderRadius="0 0 20px 20px";
}
}
else{
document.getElementById("group"+i).style.display="block";
document.getElementById("toggle"+group).src ="img/lessIcon.png";
location.hash = "#myAnchor";
if(group=="3"){
document.getElementById("backgroundSpeech").style.borderRadius="0px";
}

}
}
}

else{
document.getElementById("group"+group).style.display="none";
document.getElementById("toggle"+group).src ="img/moreIcon.png";
if(group=="3"){
document.getElementById("backgroundSpeech").style.borderRadius="0 0 20px 20px";
}
}

}

function toggleMy(my){
var isShown = document.getElementById(my).style.display;
if (!isShown || isShown=="none"){
document.getElementById(my).style.display="block";
var toWrite = "<a href=\"\javascript:toggleMy('" +my+ "');\"\>read less</a>";
document.getElementById("more"+my).innerHTML=toWrite;

}
else{
document.getElementById(my).style.display="none";
var toWrite = "<a href=\"\javascript:toggleMy('" +my+ "');\"\>read more</a>";
document.getElementById("more"+my).innerHTML=toWrite;

}

}

提前致谢!

最佳答案

我不确定你是否想要完全没有圆 Angular ,但我删除了所有的边框半径

function toggleGroup(group) {
var isShown = document.getElementById("group" + group).style.display;


if (!isShown || isShown == "none") {

for (i = 1; i <= 3; i++) {

if (i != group) {
document.getElementById("group" + i).style.display = "none";
document.getElementById("toggle" + i).src = "img/moreIcon.png";
location.hash = "#myAnchor";
if (i == "3") {
document.getElementById("backgroundSpeech").style.borderRadius = "0 0 0px 0px";
}
} else {
document.getElementById("group" + i).style.display = "block";
document.getElementById("toggle" + group).src = "img/lessIcon.png";
location.hash = "#myAnchor";
if (group == "3") {
document.getElementById("backgroundSpeech").style.borderRadius = "0px";
}

}
}
} else {
document.getElementById("group" + group).style.display = "none";
document.getElementById("toggle" + group).src = "img/moreIcon.png";
if (group == "3") {
document.getElementById("backgroundSpeech").style.borderRadius = "0 0 0px 0px";
}
}

}






function toggleMy(my) {
var isShown = document.getElementById(my).style.display;
if (!isShown || isShown == "none") {
document.getElementById(my).style.display = "block";
var toWrite = "<a href=\"\javascript:toggleMy('" + my + "');\"\>read less</a>";
document.getElementById("more" + my).innerHTML = toWrite;

} else {
document.getElementById(my).style.display = "none";
var toWrite = "<a href=\"\javascript:toggleMy('" + my + "');\"\>read more</a>";
document.getElementById("more" + my).innerHTML = toWrite;

}

}
.myGroup {
font-family: Arial;
color: #red;
background: #3399ff;
font-size: 18px;
line-height: 30px;
padding: 5px 0 0 10px;
text-align: left;
margin-bottom: 0px;
}
.myGroup img {
float: right;
padding: 5px 10px 0 0;
border: none;
}
.myGroup {
border: 0 none;
}
.group {
border-bottom: 1px solid #ffffff;
}
.group a,
.group a:hover,
.group a:active,
.group a:visited {
box-sizing: unset;
outline: none;
text-decoration: none;
}
.first {
border-radius: 0 0px 0 0;
}
.last {
border-radius: 0 0 0px 0px;
}
.noDisplay {
display: none;
}
.my {
background-color: #eee;
width: 100%;
padding: 15px 15px 30px;
border-bottom: 1px solid #ffffff;
}
.myIm {
float: left;
width: 20%
}
.myBi {
float: left;
width: 80%;
color: #363636;
font-size: 12px;
}
.myName {
float: right;
width: 80%;
color: #363636;
font-size: 12px;
text-align: left;
}
.myName h1 {
font-size: 18px;
color: #363636;
text-decoration: underline;
line-height: 18px;
font-family: 'arial';
}
.myBi span,
.myBi span a {
float: right;
color: #b00f3a;
text-decoration: underline;
}
<!-- begin dr 1-->
<a name="group1"></a>
<div class="group">
<a href="javascript:toggleGroup('1');">
<div class="first myGroup">TEST
<img src="img/moreIcon.png" id="toggle1">
</div>
</a>
<div class="noDisplay" id="group1">





<!-- -->
<div class="my">
<div class="myName">
<h1>TEST</h1>
</div>
<div class="myIm">
<img src="img/>
</div>
<div class=" myBi ">
<p>TEST </p>

<br style="clear:both; " />
</div>
<br style="clear:both; " />
</div>
<!--end -->














</div>


</div>
<!-- end dr1-->



<!-- begin dr2-->
<a name="group2 "></a> <div class="group " >
<a href="javascript:toggleGroup( '2'); " border="0 "><div class="myGroup ">TEST<img
src="img/moreIcon.png " id="toggle2 "></div></a>
<div class="noDisplay " id="group2 ">

<!-- -->
<div class="my ">
<div class="myName "><h1>TEST</h1></div>
<div class="MyIm ">

</div>
<div class=" ">
<p>TEST</p>

<br style="clear:both; " />
</div>
<br style="clear:both; " />
</div>
<!--end -->




</div>



</div>
<!-- end dr2-->








<!-- begin dr7-->
<a name="group6 "></a> <div class="group " style="padding-bottom:40px; ">
<a href="javascript:toggleGroup( '3'); " border="0 "><div class="last myGroup " id="backgroundSpeech ">TEST
<img
src="img/moreIcon.png " id="toggle3 "></div></a>
<div class="noDisplay " id="group3 ">

<!-- -->
<div class="my ">
<div class="myName "><h1>TEST</h1></div>
<div class="myIm ">
<img src="img/jpg ">
</div>
<div class="myBi ">
<p>TEST</p>

<br style="clear:both; " />
</div>
<br style="clear:both; " />
</div>
<!--end -->






</div>

</div>
<!-- end -->














</div>

关于javascript - 如何修复简单的 Javascript 下拉错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32060835/

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