jquery遍历一个数组
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <script src="http://www.lcqjgj.com/static/home/js/jquery-3.3.1.min.js"></script> <ul id="ull"> <li data-uid="aaa">1</li> <li data-uid="bbb">2</li> <li data-uid="ccc">3</li> <li data-uid="ddd">4</li> <li data-uid="eee">5</li> <li data-uid="bbb">2</li> <li data-uid="ccc">3</li> <li data-uid="ddd">4</li> <li data-uid="eee">5</li> </ul> <script> var sss = ["aaa","bbb","ccc","ddd","eee"]; var bg = ["#5a98de","#3bb4f2","#429842","#c85e0b","#c62b26"]; for(var i = 0; i < sss.length; i++){ var qwer = sss[i]; var asdf = bg[i]; // qqq = sss[i]; $("li[data-uid="+qwer+"]").css('background',asdf); } </script> </body> </html>