js创建新元素的几种方式
介绍
为了总结几种新建并插入dom元素到页面某部分的的方式,我们先搭建如下html结构。新建一个html文件,写入如下代码用chrome打开即可。
<!doctype html>
<html lang="zh">
<head>
<title>测试页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div class="dropdown-menu" id="attributes_list"></div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
</body>
</html>
有了这个html页面,我们就可以去chrome的debug console测试我们的j...