异步的解决方案-ES7的Async/Await
$(document).on('click','.fenlei,.ckgd',async function(){
var href = $(this).attr('value');
var typetitle = $(this).attr('title');
if(href == ''){
$("#recommendation").show();
}else{
$("#recommendation").hide();
}
$('.fenlei').css('background-color','');
$(".fenlei[value^='"+href+"']").css('background-color','#abc');
if(href == ''){
videoAll()
$(".resrec").show();
}else{
var cnum = await countnum(href);
LoadPageTZRL(href,typetitle,cnum);
}
});
async function videoAll() {
$("#expert").empty();
wilddog.sync().ref('').orderByChild('update_time').limitToLast(homepagesize).on("child_added", function (recommenddata) {
let n = recommenddata.val();
let i = recommenddata.key();
var rechtml = "";
$("#expert").prepend(rechtml);
});
var menulength = menuArr.length;
$(".djt").empty();
for (var j=0; j<menulength; j++)
{
mtype = menuArr[j];
var cnum = await countnum(mtype);
details(mtype,cnum)
}
}