码迷,mamicode.com
首页 > Web开发 > 详细

jQuery如何追加内容?匿名函数

时间:2017-03-28 00:05:40      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:function   tao   log   .com   query   charset   text   strong   lib   

<!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如何追加内容?匿名函数

标签:function   tao   log   .com   query   charset   text   strong   lib   

原文地址:http://www.cnblogs.com/huanghuali/p/6629445.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!