attr()

<!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').attr('title',function(index,value){
			return '原来的title'+ value + '我是'+(index+1) +'号域名';
		});
	});
	</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>

  如图显示:

 

posted @ 2017-03-27 23:07  前端HL  阅读(341)  评论(0编辑  收藏  举报