输入以获取索引号php:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="filter">
<a href="#">
<div class="type">Filter</div>
<div class="title">Cat100</div>
</a>
</div>
<div class="filter">
<a href="#">
<div class="type">Filter</div>
<div class="title">Cat200</div>
</a>
</div>
如何获取go中的索引号?
foreach much as index => each{
//get index number from index
}
答案 0 :(得分:2)
如果“范围”操作初始化变量,则该变量将设置为迭代的连续元素。另外,“范围”可以声明两个变量,以逗号分隔:
range $index, $element := pipeline
在您的示例中:
{{ range $i, $e := .post }}
Index: {{ $i }}
{{ .Id }}
{{ .Name}}
{{ end}}