关于jquery的each的操作;
1 <!doctype html> 2 <html> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 </head> 7 <body> 8 <ul> 9 <li>2222</li> 10 <li>2222</li> 11 <li>2222</li> 12 <li>2222</li> 13 <li>2222</li> 14 </ul> 15 <script src="http://libs.useso.com/js/jquery/1.8.3/jquery.min.js"></script> 16 <script> 17 var cc = $("li"); 18 var bb = []; 19 cc.each(function(inx,element){ 20 bb.push({ 21 tt:$(this).text() 22 // tt:$(element).text() 23 // 此处的element和this指代的都是本元素; 24 }) 25 }); 26 console.log(bb[0].tt); 27 </script> 28 </body> 29 </html>
坚持下去就能成功