Posted by admin on 2017年9月15日
$(‘.nav_children’).click(function(){
$(‘.dropdown-menus’).css(‘display’,’none’);
var data = $(this).attr(‘id’);
$(this).next(‘ul’).css(‘display’,’block’);
$.post(“index.php?s=home/index/unlimit”,{‘channel_id’:data},
function (res){
var lists = ”;
console.log(res);
for(var i = 0; i < res.length; i++){
lists += “<li><a href=’http://www.sealwine.com/index.php?s=”+res[i].url+”/channel_id/”+res[i].channel_id+”/cat_id/”+res[i].cat_id+”‘>”+res[i].cat_name+”</a></li>”;
}
$(‘#yyy’).next(‘ul’)(lists);
},”json”);
});
//回调函数中的for循环后边的$(‘#yyy’).next(‘ul’)(lists);因为html都是遍历出来的会有很多而id就一个 所以会导致代码不起作用逻辑上没有问题,主要是实现过程的方法出现偏差