码迷,mamicode.com
首页 > Web开发 > 详细

jQuery.克隆元素

时间:2018-07-26 13:09:42      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:bsp   nbsp   创建   html   head   type   etc   htm   tps   

克隆元素


clone()   创建匹配结果及其后代和文本

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>unwrap</title>
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.3.1.min.js">
</script>
</head>
<body>
<div>
<ul id="ul">
<li>hgfd</li>
<li>gffd</li>
<li>hgfe</li>
<li>hgef</li>
</ul>
</div>
<button>克隆</button>
<script>
$(‘button‘).on(‘click‘, function () {
$li = $(‘#d‘).clone();
$li.insertBefore(‘#a‘);
});
</script>
</body>
</html>

 

jQuery.克隆元素

标签:bsp   nbsp   创建   html   head   type   etc   htm   tps   

原文地址:https://www.cnblogs.com/H97042/p/9370782.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!