$(target).after(contentToBeInserted)
$(contentToBeInserted).insertAfter(target)
$(content).insertAfter(selector)
参数 | 说明 |
content | 这是强制性参数。它指定要插入的内容。 |
selector | 它也是必填参数。它指定插入内容的位置。> |
<!DOCTYPE html>
<html>
<head>
<script src="/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("<span><b>Hello bianchenghao6.com</b></span>").insertAfter("p");
});
});
</script>
</head>
<body>
<button>在每个p元素之后插入span元素</button>
<p>这是一个教程网站。</p>
<p>此是一家培训机构。</p>
</body>
</html>
这是一个教程网站。
此是一家培训机构。