您好,欢迎访问一九零五行业门户网

jQuery使用before()和after()在元素前后添加内容的方法

这篇文章主要介绍了jquery使用before()和after()在元素前后添加内容的方法,实例分析了jquery中before()和after()方法添加内容的技巧,非常具有实用价值,需要的朋友可以参考下
本文实例讲述了jquery使用before()和after()在元素前后添加内容的方法。分享给大家供大家参考。具体如下:
<!doctype html> <html> <head> <script src="js/jquery.min.js"> </script> <script> $(document).ready(function(){ $("#btn1").click(function(){ $("img").before("<b>before</b>"); }); $("#btn2").click(function(){ $("img").after("<i>after</i>"); }); }); </script> </head> <body> <img src="/images/w3jquery.gif" alt="jquery" width="100" height="140"> <br><br> <button id="btn1">insert before</button> <button id="btn2">insert after</button> </body> </html>
以上就是jquery使用before()和after()在元素前后添加内容的方法的详细内容。
其它类似信息

推荐信息