本文实例讲述了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>
您可能感兴趣的文章:
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!
网友评论