我很沮丧。这是我的js和html代码。 js适用于除id =" logo"之外的其他元素。它不会改变班级名称。
HTML:
<body class="beforepace">
<div id="golden" onmouseover="showdesc('golden-desc','golden');" onmouseout="hidedesc('golden-desc','golden');">
<div id="golden-desc" class="desc">Golden</div>
</div>
<div id="utopia" onmouseover="showdesc('utopia-desc','utopia');" onmouseout="hidedesc('utopia-desc','utopia');">
<div id="utopia-desc" class="desc">Utopia</div>
</div>
<div id="logo" class="default"></div>
</body>
JS:
// JavaScript Document
var logo=document.getElementById("logo");
function showdesc(a,b){
logo.className=b;
document.getElementById(a).classList.add("desc_show");
document.getElementById(b).classList.add("div-hover");
}
function hidedesc(a,b){
document.getElementById(a).classList.remove("desc_show");
document.getElementById(b).classList.remove("div-hover");
if(b==="golden")document.getElementById("logo").classList.remove("golden");
else if(b==="utopia")document.getElementById("logo").classList.remove("utopia");
}
请帮助我,非常感谢你!
答案 0 :(得分:0)
您可以检查徽标div的颜色变化
ltest['Date'].map(lambda x: x[1])
// JavaScript Document
var logo=document.getElementById("logo");
function showdesc(a,b){
logo.className=b;
document.getElementById(a).classList.add("desc_show");
document.getElementById(b).classList.add("div-hover");
}
function hidedesc(a,b){
document.getElementById(a).classList.remove("desc_show");
document.getElementById(b).classList.remove("div-hover");
if(b==="golden")document.getElementById("logo").classList.remove("golden");
else if(b==="utopia")document.getElementById("logo").classList.remove("utopia");
}
#logo{
padding-top:10px;
}
.golden{
color:yellow;
}
.utopia{
color:red;
}
答案 1 :(得分:0)
要添加新课程,请使用此
$("#logo").addClass("yourClassName");
要删除现有课程,请使用此
$("#logo").removeClass("yourClassName");