<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>Document</title></head><body> <button onclick="buttom()">提交</button> <div id="div1"></div></body><script> function buttom() { var q = ''; var count = 0; for (var i = 20; i <= 80; i++) { if (i % 3 == 0) { q += i if (count % 5 == 0) { console.log(count); document.getElementById('div1').innerHTML = q + "<br/>"; } else { document.getElementById('div1').innerHTML = q; }; count++ }; }; };</script></html>
新人求教,為什么我無法將每5個(gè)數(shù)字進(jìn)行換行打印,應(yīng)該如何操作?
函數(shù)式編程
2018-08-06 09:09:31