jQuery如何追加内容?匿名函数
jQuery 如何 函数 内容 匿名 追加
2023-09-14 08:58:24 时间
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> *{margin:0;padding:0;} </style> <script src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function(){ $('div').html(function(index,value){//通过匿名函数赋值,并传递index return value +'<em>www.taobao.com</em>'//追加<em>的内容 }); }); </script> </head> <body> <div title="11"><strong>www.baidu.com</strong></div> <div title="22"><strong>www.baidu.com</strong></div> <div title="33"><strong>www.baidu.com</strong></div> </body> </html>
这样写拓展性比较好~~~
如图显示:
相关文章
- jquery中事件委派代码分析以及jQuery中delegate和on的用法与区别详细解析
- Jquery如何获得<iframe>嵌套页面中的元素
- jQuery尺寸算法
- 有jQuery背景,该如何用AngularJS编程思想?
- jQuery源码分析系列(31) : Ajax deferred实现
- 基于jquery的获取浏览器窗口大小的代码
- JQuery模板插件-jquery.tmpl
- jQuery EasyUI 折叠面板accordion的使用实例
- Jquery学习笔记一
- jQuery UI 如何使用部件库(Widget Factory)
- jQuery下拉菜单经典案例
- 【jQuery】jQuery操作之如何查找元素_02