我遇到了JS代码的问题,我想更改元素的CSS属性“left”。我不确定什么是确切的问题。我对JS很新颖。以下代码显示了我的CSS以及我的JS代码。使用JS更改CSS属性“左”不起作用
CSS:
#Slider_Cont_Section
{
left: 0;
}
的JavaScript:
<script type="text/javascript">
function FunzioneSliderLeft()
{
var left = document.getElementById("Slider_Cont_Section").style.left;
if (left = "0px")
{
left = "0px";
}
else if (left = "-1280px")
{
left = "0px";
}
else if (left = "-2560px")
{
left = "-1280px";
}
else
{
left="-2560px";
}
</script>
<script type="text/javascript">
function FunzioneSliderRight()
{
var left = document.getElementById("Slider_Cont_Section").style.left;
if (left = "0px")
{
left = "-1280px";
}
else if (left = "-1280px")
{
left = "-2560px";
}
else if (left = "-2560px")
{
left = "-3840px";
}
else
{
left="0px";
}
</script>
“不工作”是不够的解释。请提供有关您正在尝试做什么以及出错的信息。有没有错误? – Lix 2014-09-03 09:23:18
也请尝试为您的帖子创建更有意义的标题。 – Lix 2014-09-03 09:24:00