<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 4 年前。
标签 javascript jquery html css
<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 4 年前。
我有一行输入(来自 button
类型),我想在每 3 个输入之间创建一个行间距。
所以我做了这个:
for(var i = 1; i <= 9; i++) {
if(i%3 == 0) $('#input' + i).before('<br>');
}
有人有想法吗?
编辑:
问题出在 CSS 上,我将主 div 的 display
设置为 inline-grid
。感谢所有尝试帮助的人。
最佳答案
附加<br>
在button
之后不是之前。
for (var i = 1; i <= 9; i++) {
if (i % 3 == 0)
$('#input' + i).after('<br>');
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button id="input1">a</button>
<button id="input2">b</button>
<button id="input3">c</button>
<button id="input4">d</button>
<button id="input5">e</button>
<button id="input6">f</button>
<button id="input7">g</button>
<button id="input8">h</button>
<button id="input9">i</button>
关于javascript - 输入之间的 BR 标签不会换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54783785/