console
$.ajax({
'url':'http://api.map.baidu.com/telematics/v3/weather?location=上海&output=json&ak=HGOUnCXeQLEeywhGOu2jU29PFdC6duFF',
'dataType':'jsonp',
'success':function(dat){
var str='<ul>';
str+='当前城市:'+dat.results[0].currentCity;
for(var i=0,weather=dat.results[0].weather_data,len=weather.length;
i<len;i++){
var tWeather=weather[i];
str+='<li><big class="date">'+tWeather.date+'</big></li>'
+'<li>'
+'<img src='+tWeather.dayPictureUrl+'>'
+'<img src='+tWeather.nightPictureUrl+'>'+'<br/>'
+'天气:'+tWeather.weather+'<br/>'
+'风级:'+tWeather.wind+'<br/>'
+'温度:'+tWeather.temperature+'<br/>'
+'</li>'
+'<li contenteditable="true">todolist</li>';
}
str+='</ul>'
$('#weather').html(str);
}
});
$('#weather').on('click','li:nth-child(3n+1)',function(){
console.log($(this).index())
var nextLi=$(this).next();
nextLi.stop(true,true).slideToggle();
})
<div id='wrapper'>
<div id='weather' class='pattern'></div>
</div>
body{
font-family:sans-serif;
}
#wrapper{
padding:10px;
border-left:5px solid orangered;
width:900px;
}
.pattern{
width:300px;
background:rgba(51,51,51,0.8);
box-shadow:#333 2px 2px 30px;
border-radius:30px;
text-align:left;
color:#f2f2f2;
padding:2px 5px;
vertical-align:2em;
}
li{
list-style:none;
line-height:2.5;
border-bottom:1px #fdf solid;
}
li:nth-child(3n+1){
cursor:pointer;
}
li:nth-child(3n+2){
display:none;
}
li:nth-child(3n){
font-size:12px;
color:#ddf;
}
li:nth-child(2){
display:block;
}
.date{
color:orange;
}