1 回答
TA贡献1863条经验 获得超2个赞
我不明白你要求用户进行多项操作(选择选项并单击按钮),他只需在代码中选择任何选项即可获得相应的选项。无论如何,您可以尝试下面的代码,通过单击下一步按钮获得下一个问题。(这可能是硬编码的例子:P)
<script>
$(document).ready(function () {
$('#game,#movie,#sport,#genre,#action,#adventure,#scifi,#gta,#fpp,#historic,#indoor,#outdoor,#esport').hide();
$('#hobbie input').on('change',function () {
var x = $('#game,#movie,#sport,#genre,#action,#adventure,#scifi,#gta,#fpp,#historic,#indoor,#outdoor,#esport').hide();
})
$('#movie input').change(function () {
$('#game,#sport,#action,#adventure,#scifi,#gta,#fpp,#historic,#indoor,#outdoor,#esport').hide();
})
$('#game input').change(function () {
$('#movie,#sport,#genre,#action,#game#adventure,#scifi,#gta,#fpp,#historic,#indoor,#outdoor,#esport').hide();
})
$('#sport input').change(function () {
$('#game,#movie,#genre,#action,#adventure,#scifi,#gta,#fpp,#historic,#indoor,#outdoor,#esport').hide();
})
// for button position
jQuery.fn.center = function () {
this.css("position","absolute");
this.css("top", ( $(window).height() - this.height() ) / 1.2+$(window).scrollTop() + "px");
this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
return this;
}
$('#next').center();
$("#next").on('click', function(){
var hobbieselected = $('input[name=hobbie]:checked').val();
var movieselected = $('input[name=movie]:checked').val();
var gameselected = $('input[name=game]:checked').val();
var sportselected = $('input[name=sport]:checked').val();
if(hobbieselected == 'movie'){
$('#game,#sport,#gta,#fpp,#action,#adventure,#scifi#historic,#indoor,#outdoor,#esport').hide();
$('#movie').show();
}
else if(hobbieselected == 'game'){
$('#movie,#sport,#gta,#fpp,#action,#adventure,#scifi#historic,#indoor,#outdoor,#esport').hide();
$('#game').show();
}
else if(hobbieselected == 'sport'){
$('#movie,#game,#gta,#fpp,#action,#adventure,#scifi#historic,#indoor,#outdoor,#esport').hide();
$('#sport').show();
}
if(hobbieselected == 'movie' && movieselected == 'action'){
$('#game,#sport,#adventure,#scifi,#gta,#fpp,#historic,#indoor,#outdoor,#esport').hide();
$('#action').show();
}
else if(hobbieselected == 'movie' && movieselected == 'adventure'){
$('#sport,#action,#scifi,#gta,#fpp,#historic,#indoor,#outdoor,#esport').hide();
$('#adventure').show();
}
else if(hobbieselected == 'movie' && movieselected == 'scifi'){
$('#sport,#action,#adventure,#gta,#fpp,#historic,#indoor,#outdoor,#esport').hide();
$('#scifi').show();
}
if(hobbieselected == 'game' && gameselected == 'gta'){
$('#sport,#adventure,#scifi,#action,#fpp,#historic,#indoor,#outdoor,#esport').hide();
$('#gta').show();
}
else if(hobbieselected == 'game' && gameselected == 'fpp'){
$('#movie,#sport,#genre,#action,#game#adventure,#scifi,#gta,#historic,#indoor,#outdoor,#esport').hide();
$('#fpp').show();
}
else if(hobbieselected == 'game' && gameselected == 'historic'){
$('#movie,#sport,#genre,#action,#game#adventure,#scifi,#gta,#fpp,#indoor,#outdoor,#esport').hide();
$('#historic').show();
}
if(hobbieselected == 'sport' && sportselected == 'indoor'){
$('#game,#adventure,#scifi,#gta,#fpp,#historic,#action,#outdoor,#esport').hide();
$('#indoor').show();
}
else if(hobbieselected == 'sport' && sportselected == 'outdoor'){
$('#game,#movie,#genre,#action,#adventure,#scifi,#gta,#fpp,#historic,#indoor,#esport').hide();
$('#outdoor').show();
}
else if(hobbieselected == 'sport' && sportselected == 'esport'){
$('#game,#movie,#genre,#action,#adventure,#scifi,#gta,#fpp,#historic,#indoor,#outdoor').hide();
$('#esport').show();
}
});
});
</script>
添加回答
举报