当前位置: 移动技术网 > IT编程>开发语言>JavaScript > jQuery使用after()方法在元素后面添加多项内容的方法教程

jQuery使用after()方法在元素后面添加多项内容的方法教程

2019年05月17日  | 移动技术网IT编程  | 我要评论
本文实例讲述了jquery使用after()方法在元素后面添加多项内容的方法。分享给大家供大家参考。具体分析如下: jquery可通过after()方法在元素后面添加多项内容,a

本文实例讲述了jquery使用after()方法在元素后面添加多项内容的方法。分享给大家供大家参考。具体分析如下:

jquery可通过after()方法在元素后面添加多项内容,after()可以带多个参数,在指定元素后面添加多项内容

<!doctype html>
<html>
<head>
<script src="js/jquery.min.js">
</script>
<script>
function aftertext()
{
var txt1="<b>i </b>"; // create element with html
var txt2=$("<i></i>").text("love "); // create with jquery
var txt3=document.createelement("big"); // create with dom
txt3.innerhtml="jquery!";
$("img").after(txt1,txt2,txt3); // insert new elements after img
}
</script>
</head>
<body>
<img src="/images/w3jquery.gif" alt="jquery" width="100" height="140">
<br><br>
<button onclick="aftertext()">insert after</button>
</body>
</html>

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网