//html代码
<ul id="aa"> <li>000</li> <li>111</li> <li>222</li> <li>333</li> <li>000</li> <li>111</li> <li>222</li> <li>333</li> </ul>//js代码
$(document).ready(function(){ var hotDate = new Date();//获取计算机的当前时间; for(var i=0;i<$("#aa li").length;i++){ //getTime获取距 1970 年 1 月 1 日之间的毫秒数 var dtDate = new Date(hotDate.getTime()-i*24*3600*1000); var hotYear = dtDate.getFullYear(); var hotMonth = dtDate.getMonth()+1; if(hotMonth<10){ hotMonth = "0"+hotMonth; }; var hotDay = dtDate.getDate(); if(hotDay<10){ hotDay = "0"+hotDay; }; var hotTime = "["+hotYear+"-"+hotMonth+"-"+hotDay+"]"; $("#aa li").eq(i).html(hotTime); } });