在下面的示例中,我使用了text changer
,后来有多个文本数组。我必须使用next button
来控制它。应该可以在next button
上更改文本数组。
通过Subtitle Open
打开text 1.1
并按play, stop
或reset
。然后test 2.1
应显示在next button
上方。
那并没有真正运行。有人可以帮助我吗?非常感谢。
var texter1 = new Array
texter1[0]='Text 1.1';
texter1[1]='Text 1.2';
texter1[2]='';
texter1[3]='Text 1.3';
texter1[4]='Text 1.4';
texter1[5]='Text 1.5';
texter1[6]='';
texter1[7]='End';
var i=0;
var texter2 = new Array
texter2[0]='Text 2.1';
texter2[1]='Text 2.2';
texter2[2]='';
texter2[3]='Text 2.3';
texter2[4]='Text 2.4';
texter2[5]='Text 2.5';
texter2[6]='';
texter2[7]='End';
var i1=0;
function changer(){
document.getElementById('transbox').innerHTML=texter1[i],texter2[i1];
//document.getElementById('transbox').innerHTML=texter2[i];
i++;
i1++;
if(i==texter1.length-1) i = 0;
if(i1==texter2.length-1) i1 = 0;
}
var info = document.getElementById( "transbox" );
info.style.display = "none";
function SubShow() {
info.style.display = "";
}
function SubHide() {
info.style.display = "none";
}
function SubStop() {
clearInterval( timerId );
}
function SubPlay() {
timerId = window.setInterval ( changer, 1500 );
}
function SubReset() {
i = 0
i1 = 0
changer();
clearInterval( timerId );
}
var currentArray = -1;
var previous = function previous( event ) {
currentArray -= 1;
if ( currentArray < 0 ) currentArray = changer.length - 1;
renderArray( changer[ currentArray ] );
if ( currentArray == 0 ) {
texter1();
}
if ( currentArray == 1 ) {
texter2();
}
};
var next = function next( event ) {
currentArray += 1;
if ( currentArray > changer.length - 1 ) currentArray = 0;
renderArray( changer[ currentArray ] );
if ( currentArray == 0 ) {
texter1();
}
if ( currentArray == 1 ) {
texter2();
}
};
#transbox {
font-family:Arial,sans-serif;
color:black;
text-align:center;
margin-top:50px;
}
<button type="button" onclick="SubShow()">Subtitle Open</button>
<button type="button" onclick="SubHide()">Subtitle Close</button>
<button type="button" onclick="SubPlay()">Subtitle Play</button>
<button type="button" onclick="SubStop()">Subtitle Stop</button>
<button type="button" onclick="SubReset()">Subtitle Reset</button>
<input type="button" id="prev_button" value="<< Prev" onclick= "prev_button">
<input type="button" id="next_button" value="Next >>" onclick= "next_button">
<body onLoad="changer()">
<div id="transbox"></div>