var urlstr = location.href; var urlstatus=false; console.log(urlstr); $("#navbar ul li a").each(function () { if ((urlstr + '/').indexof($(this).attr('href')) > -1&&$(this).attr('href')!='') { $(this).parent().addclass('active'); urlstatus = true; } else { $(this).parent().removeclass('active'); } }); if (!urlstatus) {$("#navbar ul li").eq(0).addclass('active'); } $('#tvlist li a').on('click',function(){ $('#tv_title').html($(this).data("title")); var myvideo =$('#my-video')[0]; myvideo.src=$(this).data("href"); myvideo.play(); }) $('#dtlist li a').on('click',function(){ $('#dt_title').html($(this).data("title")); var myaudio =$('#audios')[0]; myaudio.src=$(this).data("href"); myaudio.pause(); var oplay = $('.play')[0]; oplay.style.backgroundimage = "url(../img/pause.png)"; oplay.style.width = 29 + "px"; oplay.style.height = 36 + "px"; })