标签:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>text-button-fn.html</title> <script src="js/jquery-1.7.1.js"></script> <script> $(function(){ var divContents = [‘昨天‘,‘你‘,‘吃饭了吗‘]; $(‘.btn‘).on(‘click‘, function() { var index = $(this).index(‘.btn‘); $(‘div‘).eq(index).text(divContents[index]); }); }); </script> </head> <body> <div class="div">今天</div> <div class="div">天气</div> <div class="div">阴天</div> <button class="btn">btn1</button> <button class="btn">btn2</button> <button class="btn">btn3</button> </body> </html>
jQueryindex();eq();利用数组来操作多个事件
标签:
原文地址:http://www.cnblogs.com/shenq/p/4924688.html