Home > front end >  A question about js, bosses give directions
A question about js, bosses give directions

Time:10-02

Want to do a simple flip effect, but on the following page after each loading, directly from the first page to the third page, click back to the first page, the following page is normal, don't know why, for bosses to give directions

Js:
Var arr=[0, 1, 2, 3].
The index=0;
$(function () {
Var $yy=$(" yy ");
$yy. Get (1). The innerHTML=1;
Var $classify=$(". The classify ");
$the classify. Get (0). The style="display: block";
$the classify. Get (1). Style="display: none;"
$the classify. Get (2) style="display: none;"
$the classify. Get (3). Style="display: none;"
Var $yy=$(" yy "). The get (4). The innerHTML=arr. Length;
});
The function changePage (I) {
The index=I;
The console. The info (index);
/* alert (index); */
If (index==4) {
Alert (" has reached the last page!" );
}
If (index & lt; 0 {
The index=0;
}
If (index & gt; 3) {
The index=3;
}
Var $classify=$(". The classify ");
Var $next1=$(" next ".) get (0). The value;
$next1=arr [index];
Var $next2=$(" next ".) get (1). The value;
$next2=arr [index];
Var $yy=$(" yy "). The get (1);
The switch (index) {
Case 0:
$the classify. Get (index). Style="display: block";
$the classify. Get (index + 1). Style="display: none;"
$the classify. Get (index + 2). Style="display: none;"
$the classify. Get (index + 3). Style="display: none;"
$yy. InnerHTML=index + 1;
break;
Case 1:
$the classify. Get (index - 1). Style="display: none;"
$the classify. Get (index). Style="display: block";
$the classify. Get (index + 1). Style="display: none;"
$the classify. Get (index + 2). Style="display: none;"
$yy. InnerHTML=index + 1;
break;
Case 2:
$classify. Get (index - 2) style="display: none;"
$the classify. Get (index - 1). Style="display: none;"
$the classify. Get (index). Style="display: block";
$the classify. Get (index + 1). Style="display: none;"
$yy. InnerHTML=index + 1;
break;
Case 3:
$the classify. Get (index - 3). The style="display: none;"
$classify. Get (index - 2) style="display: none;"
$the classify. Get (index - 1). Style="display: none;"
$the classify. Get (index). Style="display: block";
$yy. InnerHTML=index + 1;
break;
}
}
HTML:

  • Related