Home >Web Front-end >JS Tutorial >Two examples of combining TopList tags and JavaScript_javascript skills

Two examples of combining TopList tags and JavaScript_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:10:361437browse

(SteamCMS) Fish Template Special Post 1: Two Examples of Combining TopList Tags and JavaScript
First, you can refer to the SteamCMS Standard Template Tag Description to learn about the TopList tag and its attributes.
Add a number before the record in the Top list (of course it can also be a picture, here is just a simple example).
Principle description: First initialize a js variable at the front, in the middle of TopList, add 1 to the Js variable, and output it in the middle of the TopList loop body (the same reason I write asp code)

Key code:





.





In the code, the green part defines a global variable i and a function doit. The doit function runs in the red part of the loop body and outputs i. Blue is the TopList label. The dark yellow behind the red code is the title. The result of the above code will be to add a number before each record. Keep it simple. hey-hey.


Second example: Insert a blank line every fifth line, such as:
Insert a blank line every fifth line in the Top list (of course it can also be a picture, or other responsible code).
Principle description: First initialize a js variable at the front, in the middle of TopList, add 1 to the Js variable, and calculate whether the js variable is divisible by 5 in the TopList loop body, and if so, output a blank line.



Key code:











<script> <BR>//全局变量 <BR>var i=1; <BR>//输出i,并i自增 <BR>function doit(){ <BR>document.write(i); <BR>i++; <BR>} <BR></script><script>doit();</script><script> <BR>//全局变量 <BR>var i=1; <BR>//输出i,并i自增 <BR>function doit(){ <BR>if(i%5==0){//是否被5整除 <BR> document.write("<br />"); <BR>} <BR>i++; <BR>} <BR></script>In the code, the green part defines a global variable i and a function doit. The doit function runs in the red part of the loop body and determines whether it is divisible by 5. If so, it outputs <script>doit();</script>. Blue is the TopList label. The yellow in front of the red code is the title. The result of the above code will be to insert a blank line every fifth line. Keep it simple. hey-hey.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn