简体   繁体   中英

How to put a variable in the id inside the html tag?

I am wondering how to put a variable in the id inside the html tag. I came across this issue while implementing pagination. Like that picture, I want the i+1 part of the value of id="page-box-i+1" to be replaced with an actual number, not a string. For example, if i is 2, I want it to be id="page-box-3". How can it be solved? I am implementing it in an vue.js & ejs file.

在此处输入图像描述

Use v-bind attribute:

<div v-bind:id="'page-box-' + (i + 1)"></div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM