$.each的用法
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <div class="box"> <ul class="uls"> <li>11111</li> <li>22222</li> <li>99999</li> <li>55555</li> <li>33333</li> </ul> </div> </body> </html> <script src="https://code.jquery.com/jquery-1.11.3.js"></script> <script> //实现的效果.每点击一个li标签,相应的li标签后面加一个index值 var lis = $("ul.uls li"); $.each(lis, function (index, item) { console.log(index); console.log(item); $(this).on('click', function () { var value = '后面接' + index; $(this).append(value); }) }) </script>