Html 如何每6个拆分

Html 如何每6个拆分,html,ejs,Html,Ejs,例如,我这里有我的代码,我想添加每6里的 我尝试在if语句中插入ul,但它不起作用。是否可以在不将ul置于if之外的情况下放置ul 有关更易于阅读的注释: // start <ul> for(var j = 0, k = 0; j < array4.length; j++) { if(array4[j].input_type == "radio") { // add <li> here // if we're not at the begin

例如,我这里有我的代码,我想添加每6里的

我尝试在if语句中插入ul,但它不起作用。是否可以在不将ul置于if之外的情况下放置ul

有关更易于阅读的注释:

// start <ul>
for(var j = 0, k = 0; j < array4.length; j++) {
  if(array4[j].input_type == "radio") {

    // add <li> here

    // if we're not at the beginning of the array
    // and we're on a multiple of 6
    // and we're not at the end of the array
    if(k > 0 && !(k%6) && array4.length-1 != j) { 

      // close one <ul> and open another

    }
    k++;
  }
}
// end <ul>

也被称为模数运算符使这更容易。

您可以使用mod.%你说mod%是什么意思?@JohnCarloVelasquez你用的是什么语言?不是Javascript或HTML。我猜是PHP。你的LI是在一个循环中生成的吗?我使用Node.JS,是的,它是由一个loop@JohnCarloVelasquez是的,我原以为你在用PHP。我已经为node.js更新了它。先生,如果条件是对所有相同的变量进行排序,我可以问一下是否可以使用if语句,例如我的name=[a,a,a,a,a,x,x,y,y,z,z]@JohnCarloVelasquez很酷,很高兴我能帮上忙。如果你觉得有用,请随意投票。如果答案最符合你的需要,也可以随意标记为已接受。@JohnCarloVelasquez这听起来像是一个单独的问题。请随意发布另一个问题,以便能够自行解决。
// start <ul>
for(var j = 0, k = 0; j < array4.length; j++) {
  if(array4[j].input_type == "radio") {

    // add <li> here

    // if we're not at the beginning of the array
    // and we're on a multiple of 6
    // and we're not at the end of the array
    if(k > 0 && !(k%6) && array4.length-1 != j) { 

      // close one <ul> and open another

    }
    k++;
  }
}
// end <ul>