Javascript 我没有';在我的页面中看不到我的按钮
在我的HTML页面中,我没有看到我的按钮…请帮助我Javascript 我没有';在我的页面中看不到我的按钮,javascript,html,css,Javascript,Html,Css,在我的HTML页面中,我没有看到我的按钮…请帮助我 #container { position:relative; width:700px; height:400px; border: 2px solid black; background-color:#888; margin: 50px auto 0px; overflow:hidden; } .box { position:relative; width:600
#container
{
position:relative;
width:700px;
height:400px;
border: 2px solid black;
background-color:#888;
margin: 50px auto 0px;
overflow:hidden;
}
.box
{
position:relative;
width:600px;
height:300px;
border: 1px solid black;
margin: 50px auto 0px;
overflow:hidden;
}
#button
{
margin:47%;
position:absolute;
margin-top:2%;
}
JAVASCRIPT:
<script type="text/javascript">
var $c =0;
function next()
{
var boxes = document.getElementsByClassName("box");
$c +=1;
if($c >= boxes.length) $c = 0;
for (var $i=0;$i<boxes.length;$i++)
{
boxes[$i].style.display = "none";
}
boxes[$c].style.display = "block";
return false;
}
function prev()
{
var boxes = document.getElementsByClassName("box");
$c -=1;
if($c < 0) $c = (boxes.length-1);
for (var $i=0;$i<boxes.length;$i++)
{
boxes[$i].style.display = "none";
}
boxes[$c].style.display = "block";
return false;
}
</script>
var$c=0;
函数next()
{
var-box=document.getElementsByClassName(“box”);
$c+=1;
如果($c>=box.length)$c=0;
对于(var$i=0;$i试试这个
.box {
border: 1px solid black;
float: left;
height: 300px;
margin: 50px 45px;
overflow: hidden;
position: relative;
width: 600px;
}
这可能是因为您在按钮中使用了
,因此浏览器对HTML的解释是错误的
请尝试
查看
和
查看不要写我不知道这是什么意思,请编辑此问题,使其成为一个实际问题,您可以提供有关您的问题和任何错误的足够详细信息。如果您看到这些问题,您现在确实看到了,因此问题已得到解决可能是一个打字错误在您的问题中,但您的div id按钮上也缺少引号,MarkWalters:它是完全有效的,并且将实现您所期望的功能。(如果您希望空格使其成为新属性,则它不会;空格将被忽略。)然而,请注意,容器
和按钮
不是好的ID。它们是应该成为类的东西。相同的bat时间,相同的bat频道…通过编辑它,我也没有解决我的问题。。
.box {
border: 1px solid black;
float: left;
height: 300px;
margin: 50px 45px;
overflow: hidden;
position: relative;
width: 600px;
}
<div id= button>
<button id="bwd" onclick="return prev()"><<</button>
<button id="fwd" onclick="return next()">>></button>
</div>
<div id= button>
<button id="bwd" onclick="return prev()"><<</button>
<button id="fwd" onclick="return next()">>></button>
</div>