<!-- hot live --><divclass="hotlive clearfix"><!-- title --><h3class="fl">热门直播</h3><divclass="more fr">
<a href="#" class = "fl">更多</a>
<i class = "iconfont icon-jiahao1 fl"></i></div><divstyle="clear: both;"></div><!-- content -->
<div class="hotcontent clearfix" id = "hotcontent">
<!-- hot image -->
<div class = "active hotimg"></div>
<div class = "hotimg"></div>
<div class = "hotimg"></div>
<div class = "hotimg"></div>
<div class = "hotimg"></div>
<p class = "active sequence"></p>
<p class = "sequence"></p>
<p class = "sequence"></p>
<p class = "sequence"></p>
<p class = "sequence"></p><divclass="notstart"><iclass="iconfont icon-icon-"></i>
未开始
</div><!-- hot description -->
<ul class="hotdesc fr" id = "hotdesc">
<li><divclass="time"></div><h3></h3></li><li><divclass="time"></div><h3></h3></li><li><divclass="time"></div><h3></h3></li><li><divclass="time"></div><h3></h3></li><li><divclass="time"></div><h3></h3></li></ul></div></div>
// 3.Realization of hot live list// 3.1 Ajax request data (img/desc/time)ajax('get','../data/hot.json','',function(res){// console.log(res);// Transform datavar hotUrl =JSON.parse(res);
console.log(hotUrl);// Rendering the page, comment previous static data in html page// Get father elementvar hotContent = document.getElementById('hotcontent');// console.log(hotContent);var hotImage = hotContent.getElementsByClassName('hotimg');var sequence = hotContent.getElementsByClassName('sequence');// console.log(hotImage, sequence);// Rendering image and sequencefor(var i =0; i < hotUrl.length; i++){
hotImage[i].innerHTML ='<img src='+ hotUrl[i].src +' alt="hot"></img>';
sequence[i].innerHTML = hotUrl[i].name;}// Rendering data to the right panel// Get father element hotdescvar hotDesc = document.getElementById('hotdesc');// console.log(hotDesc);// Get element time and h3var time = hotDesc.getElementsByClassName('time');var h3 = hotDesc.getElementsByTagName('h3');// console.log(time, h3);// Rendering time and desc into time and h3for(var i =0; i < hotUrl.length; i++){
time[i].innerHTML ='<span>'+ hotUrl[i].time +'</span>';
h3[i].innerHTML ='<a href="#">'+ hotUrl[i].name +'</a>';}/*
Tab function, click each li to get the content of corresponding payment,
and the background color of li is programmed in pink
*/// Get element li from father element hotDescvar lis = hotDesc.getElementsByTagName('li');// console.log(lis);for(var i =0; i < lis.length; i++){// custom index to save index
lis[i].index = i;// event: when mouse enter into li
lis[i].onmouseenter=function(){this.style.backgroundColor ='#FFF7F3';// console.log(this.index);// exclusivefor(var j =0; j < lis.length; j++){
hotImage[j].className ='hotimg';
sequence[j].className ='sequence';}// shift
hotImage[this.index].className ='active hotimg';
sequence[this.index].className ='active sequence';}// when mouse leave the li, background turn to white
lis[i].onmouseleave=function(){this.style.backgroundColor ='#ffffff';}}});