您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > JavaScriptjs动态更换播放图片特效
[javascript]viewplaincopyprint?1.!DOCTYPEHTMLPUBLIC-//W3C//DTDHTML4.01Transitional//EN2.html3.head4.titletab.html/title5.metahttp-equiv=keywordscontent=keyword1,keyword2,keyword36.metahttp-equiv=descriptioncontent=thisismypage7.metahttp-equiv=content-typecontent=text/html;charset=UTF-88.styletype=text/css9..subject{10.border:1pxsolidblack;11.width:200px;12.height:200px;13.}14./style15.scripttype=text/ahref=='replace_word'title=JavaScript知识库target='_blank'style='color:#df3434;font-weight:bold;'JavaScript/a16.varimgAry=newArray();17.imgAry.push();18.imgAry.push();19.imgAry.push();20.imgAry.push();21.imgAry.push();22.23.window.onload=function(){24.varoBox=document.getElementById(subjectBox);25.varoShowId=document.getElementById(showId).value;26.varsubjectHtml=;27.for(vari=1;i=4;i++){28.if(i==oShowId){29.subjectHtml+=divid='div_+i+'name='showDiv'style='display:block;'class='subject'+i+imgsrc='+imgAry[i-1]+'//div30.}else{31.subjectHtml+=divid='div_+i+'name='showDiv'style='display:none;'class='subject'+i+imgsrc='+imgAry[i-1]+'//div}33.}34.oBox.innerHTML=subjectHtml;35.showSubject2(next);36.};37.38.functionsetHide(){39.varallDiv=document.getElementsByName(showDiv);40.for(vari=0;iallDiv.length;i++){41.if(allDiv[i].style.display!=none){42.allDiv[i].style.display=none;43.}44.}45.}46.47.48.//方法一:49.functionshowSubject(flag){50.varoShowId=document.getElementById(showId).value;51.varallDiv=document.getElementsByName(showDiv);52.varlen=allDiv.length;53.//alert(oShowId+:+len);54.setHide();//隐藏所有div55.if(flag==next){56.oShowId=eval(oShowId)+1;57.if(oShowIdlen){58.oShowId=1;59.}60.document.getElementById(div_+oShowId).style.display=block;61.}else{62.oShowId=eval(oShowId)-1;63.if(oShowId1){64.oShowId=len;65.}66.document.getElementById(div_+oShowId).style.display=block;67.}68.document.getElementById(showId).value=oShowId;69.}70.71.//方法二:72.functionshowSubject2(flag){73.varallDiv=document.getElementsByName(showDiv);(vari=0,len=allDiv.length;ilen;i++){75.if(allDiv[i].style.display==block){76.allDiv[i].style.display=none;77.if(flag==next){78.if(ilen){79.i+=1;80.}81.if(i=len){82.i=0;83.}84.}else{85.if(i0){86.i-=1;87.}88.if(i=0){89.i=len-1;90.}91.}92.allDiv[i].style.display=block;93.break;94.}95.}96.setTimeout(showSubject2('next'),1000);//动态更换图片97.}98./script99./head100.101.body102.方法1:103.inputtype=buttonvalue=上onclick=showSubject('prev')/104.inputtype=buttonvalue=下onclick=showSubject('next')/105.inputtype=hiddenid=showIdvalue=1/106.br/107.方法2:108.inputtype=buttonvalue=上onclick=showSubject2('prev')/109.inputtype=buttonvalue=下onclick=showSubject2('next')/110.divid=subjectBox111./div112./body113./html
本文标题:JavaScriptjs动态更换播放图片特效
链接地址:https://www.777doc.com/doc-2880389 .html