<!DOCTYPE html> <html> <head> </head> <body> <h1> 这是H1 </h1> <div id="div1"> </div> <script type="text/html" id="toolbar"> <input type="text" class="larry-input" style="height:100%;" name="username" id="username" placeholder="按名称查询"> <button class="layui-btn layui-btn-sm" lay-event="add" data-url="/Backstage/Person/Add">新增</button> <button class="layui-btn layui-btn-sm layui-btn-danger isDelete" id="pici" data-url="/Backstage/Person/BatchDel">批量删除</button> </script> <script type="text/javascript"> var t = document.getElementById("toolbar"); var t_html = t.innerHTML; var t_text =t.innerText; var username = document.getElementById("username");//获取的是null var div = document.getElementById("div1"); div.innerHTML = t_html; div.innerHTML = t_text; username = document.getElementById("username");//获取的不为null var t1 = 0; </script> </body> </html>