正如标题所说,我不能使用 .insertAdjacentHTML 因为我只是不知道如何使用。
for(let i=1;i<=m;i++)
{
for(let j=1;j<=n;j++)
{
document.querySelector(".matrice-" + p).insertAdjacentHTML('beforeend', '<input class="l' + i + 'c' + 'j" size="3" maxlength="4" inputmode="numeric"></input>')
}
document.querySelector(".matrice-" + p).insertAdjacentHTML('beforeend', '<br/>')
}
}
我希望输入类像 l1c1 l1c2 l1c3 等等,但我似乎无法让 j 作为变量工作。它被用作字符串,所以我所有的类都是 l1cj l2cj 等等。
我必须使用这么多引号的事实真的让我感到困惑。
我应该如何使用它来获得预期的效果?