项目描述
上传时间
浏览人数
1)div部分
<div class="container"> <div class="row justify-content-center"> <div class="col-xxl-4 col-xl-4"></div> <div class="col-xxl-4 col-xl-4"> <div class="row mt-5"> <div class="col-xl-4"> <input type="text" id="jkl" class="form-control"> </div> <div class="col-xl-4"> <button type="button" class="btn btn-primary" onclick="face()">切换昵称</button> </div> <div class="col-xl-4"></div> </div> </div> <div class="col-xxl-4 col-xl-4"></div> </div> </div>
2)js部分
function change() { face() } function face() { let all="赵钱孙李周吴郑王冯陈褚卫\n" + "蒋沈韩杨朱秦尤许何吕施张\n" + "孔曹严华金魏陶姜戚谢邹喻\n" + "柏水窦章云苏潘葛奚范彭郎\n" + "鲁韦昌马苗凤花方俞任袁柳\n" + "酆鲍史唐费廉岑薛雷贺倪汤\n" + "滕殷罗毕郝邬安常乐于时傅\n" + "皮卞齐康伍余元卜顾孟平黄\n" + "和穆萧尹姚邵湛汪祁毛禹狄\n" + "米贝明臧计伏成戴谈宋茅庞\n" + "熊纪舒屈项祝董梁杜阮蓝闵\n" + "席季麻强贾路娄危江童颜郭\n" + "梅盛林刁钟徐邱骆高夏蔡田\n" + "樊胡凌霍虞万支柯昝管卢莫\n" function randInt(min, max) { return parseInt(Math.random() * (max - min + 1)) + min; } let alllength=randInt(3,6); let maxIdx = all.length - 1; let name = ""; for (let i = 0; i < alllength; i++) { let x = randInt(0, maxIdx); let r = all[x]; // console.log(randChar); name = name + r; } $("#jkl").val(name); }