网页中一条JS可以多次调用么?帮写下第二个源代码,让两个都能被JS同时被调用。谢谢了
<script>var$=function(id){returndocument.getElementById(id)};varwrap=$("wrap");vara=$...
<script>
var $ = function(id){return document.getElementById(id)};
var wrap = $("wrap");
var a = $("a");
var b = $("b");
var show = $("show");
var d;
b.innerHTML = a.innerHTML;
function scrolls(){
d = "n";
if(b.offsetWidth - wrap.scrollLeft <=0){
wrap.scrollLeft = wrap.scrollLeft - b.offsetWidth;
}
else{
wrap.scrollLeft++;
}
}
t = setInterval("scrolls()",10)
function backScrolls(){
if(wrap.scrollLeft <=0){
wrap.scrollLeft = wrap.scrollLeft + b.offsetWidth;
}
else{
wrap.scrollLeft--;
}
}
function left(){
d = "n";
clearT();
t = setInterval("scrolls()",10);
}
function right(){
d = "m";
clearT();
t = setInterval("backScrolls()",10);
}
function clearT(){
clearInterval(t);
}
function runs(){
if(d == "n"){
left();
}
else{
right();
}
}
wrap.onmouseover = function (){
clearT();
}
wrap.onmouseout = function(){
runs();
}
</script>
<div id="wrap">
<div id="scrolls">
<div id="a">
<ul>
<li><img src="images/tu_101.png" / alt="历届精彩回顾"></li>
<li><img src="images/tu_103.png" /alt="历届精彩回顾"></li>
<li><img src="images/tu_101.png" / alt="历届精彩回顾"></li>
<li><img src="images/tu_101.png" / alt="历届精彩回顾"></li>
<li><img src="images/tu_103.png" / alt="历届精彩回顾"></li>
<li><img src="images/tu_101.png" / alt="历届精彩回顾"></li>
<li><img src="images/tu_101.png" / alt="历届精彩回顾"></li>
<li><img src="images/tu_101.png" / alt="历届精彩回顾"></li>
<li><img src="images/tu_101.png" / alt="历届精彩回顾"></li>
</ul>
</div>
<div id="b"> </div> 展开
var $ = function(id){return document.getElementById(id)};
var wrap = $("wrap");
var a = $("a");
var b = $("b");
var show = $("show");
var d;
b.innerHTML = a.innerHTML;
function scrolls(){
d = "n";
if(b.offsetWidth - wrap.scrollLeft <=0){
wrap.scrollLeft = wrap.scrollLeft - b.offsetWidth;
}
else{
wrap.scrollLeft++;
}
}
t = setInterval("scrolls()",10)
function backScrolls(){
if(wrap.scrollLeft <=0){
wrap.scrollLeft = wrap.scrollLeft + b.offsetWidth;
}
else{
wrap.scrollLeft--;
}
}
function left(){
d = "n";
clearT();
t = setInterval("scrolls()",10);
}
function right(){
d = "m";
clearT();
t = setInterval("backScrolls()",10);
}
function clearT(){
clearInterval(t);
}
function runs(){
if(d == "n"){
left();
}
else{
right();
}
}
wrap.onmouseover = function (){
clearT();
}
wrap.onmouseout = function(){
runs();
}
</script>
<div id="wrap">
<div id="scrolls">
<div id="a">
<ul>
<li><img src="images/tu_101.png" / alt="历届精彩回顾"></li>
<li><img src="images/tu_103.png" /alt="历届精彩回顾"></li>
<li><img src="images/tu_101.png" / alt="历届精彩回顾"></li>
<li><img src="images/tu_101.png" / alt="历届精彩回顾"></li>
<li><img src="images/tu_103.png" / alt="历届精彩回顾"></li>
<li><img src="images/tu_101.png" / alt="历届精彩回顾"></li>
<li><img src="images/tu_101.png" / alt="历届精彩回顾"></li>
<li><img src="images/tu_101.png" / alt="历届精彩回顾"></li>
<li><img src="images/tu_101.png" / alt="历届精彩回顾"></li>
</ul>
</div>
<div id="b"> </div> 展开
2个回答
2011-08-26
展开全部
ss
追问
#wrap{width:970px;height:120px;overflow:hidden; float:left; margin-left:3px;}
#a li,#b li{float:left;width:142px;height:93px; margin:10px 0 0 10px; float:left; display:inline;}
#scrolls{width:200%;float:left;}
#a,#b{float:left;}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询