代码学习:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Nearth</title> <style type="text/css"> div{ width:200px; height: 200px; background-color: paleturquoise; } </style> <script src="jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> //要求:点击按钮创建一个p 标签添加到div 中 $(function(){ $("#btn").click(function(){ $("#dv").html("<p>这是一个p标签</p>") }); }); </script> </head> <body> <h1>动态创建元素的另一种方式</h1> <hr > <input type="button" name="" id="btn" value="创建元素" /> <div id="dv"></div> </body> </html>
Nearth===>WEB前端--第24课/JQuery/动态创建元素4(点击按钮,添加元素的另外一种方式)
最新推荐文章于 2021-04-15 21:25:52 发布