我想让每个div依次显示color里面的颜色,这么写哪里错了呢?
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title></title> <script src="http://code.jquery.com/jquery-1.11.3.js"></script> </head> <body> <div>元素一</div> <div>元素二</div> <div>元素三</div> <div>元素四</div> <div>元素五</div> <script type="text/javascript"> $(function(){ var color = ["tomato","green","aqua","gold","lightgreen"] for(var i = 0;i<color.length;i++){ $("div:eq(i)").css("color",color[i]); } }) </script> </body> </html>
我想让每个div依次显示color里面的颜色,这么写哪里错了呢?