function getSelectedTabID() { return tabID = $('.mod-tabs-trigger .selected').first().attr('id'); } function searchHeroes(searchKey) { var size = allHeroes.length; var outputHtml = '搜索结果:'; for(var i=0;i -1) || (cname!=null && cname.indexOf(searchKey) >-1) || (title!=null&&title.indexOf(searchKey) >-1)) { outputHtml += ""+cname+"("+title+") "; } } } $('#searchResult').html(outputHtml); } $( document ).ready(function() { $('#searchKey').focus(function() { if(this.value=='请输入英雄名称关键字') { this.value=''; } }); $("#searchKey").keyup(function (event) { if (event.keyCode == 13) { searchHeroes(document.getElementById('searchKey').value); } }); $('#btnHeroSearch').bind("click", function (event) { searchHeroes(document.getElementById('searchKey').value); }); // binding for tab onClicked $('.mod-tabs-trigger li').bind('click', function(event) { $(this).siblings().removeClass('selected').end().addClass('selected'); var rankType = getSelectedTabID(); if (rankType == 'R_S_5') { window.location = 'rankScoreRank.php'; } else if (rankType == 'zdlRank') { window.location = 'zdlRank.php'; } else if (rankType == 'heroRank') { window.location = 'heroesRank.php'; } }); });