<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div class="box">
hello
</div>
<div class="box2">
!!!
</div>
<script src="lib/jquery-2.2."></script>
<script>
//after和before的调用者必须是已存在的元素
// $('.box').after("<div class='box1'>world</div>");
// $('.box').before("<div class='box1'>world</div>");
//换位置
// $('.box').before($('.box2'));//before不能使用字符串型参数,只能先找到元素
//insertBefore
$('.box').insertBefore($('.box2'));
//insertAfter
$('.box').insertAfter($('.box2'));
</script>
</body>
</html>