Home > front end >  Could you tell me how to modify the code implementation after the click operation of value default v
Could you tell me how to modify the code implementation after the click operation of value default v

Time:10-06

Could you tell me how to modify the code to achieve click nowPages value plus one after the operation?
Effect (the original code is click on the calendar, then page displays the next date, I did some modification, hope after click on the page, nowPages value plus one, and then show the new nowPages value content of the case, until 7 no longer pages)


The code below

Var pages=document. QuerySelector (' pages');
Var locale=window. The navigator. Language | | 'en - us;
Var nowPages=1;//this value as the default values, click on the need to implement after the value plus one, and then the switch output related to content

The function handleClick (e) {
UpdateCalendar (e. arget);
}

The function updateCalendar (target) {
If (target & amp; & Target. The classList. The contains (' page ')) {
Target. The classList. Add (' tear ');
SetTimeout (function () {
Pages. RemoveChild (target);
}, 800);
} else {
return;
}
RenderPage ();
}

The function renderPage () {
Var brought=document. The createElement method (' div ');
Brought. The classList. Add (' page ');
If (nowPages<7) {
The switch (nowPages)
{
Case 1:
Code;
break;

Case 2:
Code;
break;

Case 3:
Code;
break;

Case 4:
Code;
break;

Case 5:
Code;
break;

Case 6:
Code;
break;
}
}

Brought by the innerHTML='\ n




'& lt;/p> \ n & lt; P & gt; '+ contentB +
'& lt;/p> \ n & lt; P & gt; '+ contentC +
'& lt;/p> \ n & lt; P & gt; + '
'& lt;/p>






';

Pages. The appendChild (brought);
}
RenderPage ();

Pages. AddEventListener (' click ', handleClick);

CodePudding user response:

Resolved, the original js can directly change the global variable

  • Related