我有一个简单的javascript,可以在轮到显示时向滑块添加样式,但是我想在下一个滑块出现时删除样式,并且在鼠标悬停时删除这两种样式。
这是我的 javascript 函数,将 style="width: 200px" 添加到新滑块并将 style="width: 200px" 添加到旧滑块。
function test(){
var read = document.getElementById("slide-0") // how can i add here to read the incremented slide-0, slide-1, slide-2
.removeAttribute("style",0);
}
function noEffect(pOld,pNew){
if (pOld){
pOld.style.width='10px';
}
if (pNew){
pNew.style.width='200px'; //this style become on active slider.
}
}
滑块html
<div class="slider" onMouseOver="test()">
<ul>
<li id="slide-0" class="slide" style="width: 10px"><img src="image.jpg"></li>
<li id="slide-1" class="slide" style="width: 200px"><img src="image.jpg"></li> <!-- this is active now -->
</ul>
</div>
正是我想要的是在鼠标悬停时删除两者的样式。
任何帮助表示赞赏。