我正在使用jquery根据篮球系列的获胜者动态淡入内容。举例来说,让我们参加NBA东部决赛。这是七个系列中的一个。赢得四场比赛的第一支队伍获胜。所以,如果对于第一个输入标签,用户选择芝加哥公牛作为他们的赢家。对于第二场比赛,用户选择迈阿密热队作为他们的赢家。基于迄今为止的这些结果,jquery将不得不在额外的输入标签中褪色,因为显然该系列至少要打5场比赛。动态淡入html值根据值
这是非常基本的。但是,如果客户想回去编辑游戏的获胜者,会不会有人想到如何去做这件事,这会让他们相应地淡入淡出。我可以使用大量的条件语句来做到这一点,但我真的很想得到一些想法,因为它涉及更有效的方法。
<script type="text/javascript">
$(document).ready(function(){
var data = <?php echo $teamone_ac; ?>;
var soulja = <?php echo $teamtwo_ac; ?>;
var away_team_other = $('.away_team_other').html();
var home_team_other = $('.home_team_other').html();
var away_team_wild = $('.away_team_wild').html();
var home_team_wild = $('.home_team_wild').html();
$("#game_one_other").autocomplete({ source: data });
$("#game_two_other").autocomplete({
source: data,
select: function(event, ui)
{
var game_one_other = $('#game_one_other').val();
var game_two_other = ui.item.value;
var game_three_other = $('#game_two_other').val();
var arr = [game_one_other, game_two_other, game_three_other, game_four_other, game_five_other];
var away = away_team_other;
var home = away_home_other;
var numAway = $.grep(arr, function (elem) {
return elem === away;
}).length;
var numHome = $.grep(arr, function (elem) {
return elem === home;
}).length;
if(game_one_other != game_two_other)
{
$('#one_four').fadeIn('slow');
}
}
});
$("#game_three_other").autocomplete({
source: data,
select: function(event, ui)
{
var game_one_other = $('#game_one_other').val();
var game_two_other = $('#game_two_other').val();
var game_three_other = ui.item.value;
if(game_two_other == game_three_other && game_two_other != game_one_other)
{
$('#one_four').fadeIn('slow');
}
}
});
$("#game_one_wild").autocomplete({ source: soulja });
$("#game_two_wild").autocomplete({ source: soulja });
$("#game_three_wild").autocomplete({ source: soulja });
$('#one_four').hide();
$('#one_five').hide();
$('#two_four').hide();
$('#two_five').hide();
});
你有一个工作的例子,以更好地说明这个想法? – 2011-05-14 20:50:04
我会发布代码 – Lance 2011-05-14 20:51:01
Yuck。我们不要这样做,并说我们做到了。 – 2011-05-14 21:43:53