本文实例讲述了jquery使用prepend()方法在元素前添加内容的用法。分享给大家供大家参考。具体分析如下:
下面的代码可实现在文本前和列表前添加新的元素
<!doctype html> <html> <head> <script src="js/jquery.min.js"> </script> <script> $(document).ready(function(){ $("#btn1").click(function(){ $("p").prepend("<b>prepended text</b>. "); }); $("#btn2").click(function(){ $("ol").prepend("<li>prepended item</li>"); }); }); </script> </head> <body> <p>this is a paragraph.</p> <p>this is another paragraph.</p> <ol> <li>list item 1</li> <li>list item 2</li> <li>list item 3</li> </ol> <button id="btn1">prepend text</button> <button id="btn2">prepend list item</button> </body> </html>
如对本文有疑问, 点击进行留言回复!!
asp.net中ajax和一般处理程序(handler.ashx)的交互
egg.js创建项目,目录介绍,简单使用,sequelize mysql使用
网友评论