求一段js。。。。
<div class="pxl_2" id="move" style="overflow:hidden">
<div class="pxl_2_1" id="seconde" style="width:<%=width%>px; height:140px;">
<asp:Repeater ID="rep" runat="server">
<ItemTemplate>
<div style="margin-left:10px; float:left" class="pic"><a href='products.aspx?protype=<%#Eval("firprotype") %>'><img src='<%#Eval("proimage") %>' class="img" /></a></div>
</ItemTemplate>
</asp:Repeater>
</div>
<div id="demo2"></div>
</div>
使中间的图片区域滚动起来。。。自己写了一个如下
<script>
var speed = 30;
var demo = document.getElementById("move");
var demo1 = document.getElementById("seconde");
var demo2 = document.getElementById("demo2");
demo2.innerHTML = demo1.innerHTML;
function myMarquee() {
if (demo2.offsetWidth - demo.scrollLeft <= 0)
demo.scrollLeft -= demo1.offsetWidth;
else {
demo.scrollLeft++;
}
}
var MyMar = setInterval(myMarquee, speed);
demo.onmouseover = function () { clearInterval(MyMar) }
demo.onmouseout = function () { MyMar = setInterval(myMarquee, speed) }
</script>
可是不管用,调试说demo1.innerhtml的值为null
------解决方案--------------------调试demo1.innerhtml的值为null的原因是,应该是div还没有生成就document.getElementById,将script写在div的下面,或者写onload事件.