【发布时间】:2015-07-03 22:15:20
【问题描述】:
我试图为用户创建一个开放的环境来选择一个特定的选项,同时给他们以任何顺序选择它们的开放机会,同时消除他们选择的选项。到目前为止,我的代码在乱序执行时会阻止我。基本上选择和选项会在一个跨度内弹出。他们选择一个。结果在该范围内交付,并且出现相同的选项,但消除了他们已经选择的选项。
这是 HTML 代码
<div><select id="lies">
<option value="" selected='selected'>Select a lie...</option>
<option value="FBI">We're undercover agents</option>
<option value="super">We're superheroes</option>
<option value="confess">We're the bombers</option>
</select></div>
<span id='FBI'>
<p>"We're undercover students working with the FBI," you say.</p>
<p>"Get outta here before I put you both in cuffs!" he yells.</p>
<p>"Good job, <?php echo $_GET['Name']?>! You almost got us busted.." </p>
<p>"Come on, Korra, let's try one more! Over there!" you exclaim.</p>
<div><select id="lies">
<option value="" selected='selected'>Select a lie...</option>
<option value="FBI">We're undercover agents</option>
<option value="super">We're superheroes</option>
<option value="confess">We're the bombers</option>
</select></div>
</span>
<span id='super'>
<p>"Let us through, we're bulletproof!" you fearlessly say.</p>
<p>"Are ya now?" asks the cop as he lightly bops you over the head with his fist.</p>
<p>"OW!" you yell.</p>
<p>"Run along and go play somewhere else, stupid kid!"</p>
<p>You and Korra walk away feeling defeated.</p>
<p>"Any other ideas, <?php echo $_GET['Name']?>?" she asks.</p>
<p>"One more try!" you say as you run over to another police officer.</p>
<div><select id="lies">
<option value="" selected='selected'>Select a lie...</option>
<option value="FBI">We're undercover agents</option>
<option value="super">We're superheroes</option>
<option value="confess">We're the bombers</option>
</select></div>
</span>
<span id='confess'>
<p>"It was us!"</p>
<p>"Alright off to jail you go!" says the officer.</p>
You get escorted off to jail. THE END.
</span>
这里是 jQuery
//Keeps the spans containing the respondes hidden until an option is selected for the lietocops page
$('#lies').change(function(){
var contact = $(this).val();
// Hides the list / show list
if ( contact == ""){
$('#lies').show();
}else{
$('#lies').hide();
}
$("#lies option:selected").attr('disabled','disabled')
.siblings().removeAttr('disabled');
// lie responses
if( contact == "FBI") {
$('#FBI').fadeIn();
}else if( contact == "super") {
$('#super').fadeIn();
}else if( contact == "confess") {
$('#confess').fadeIn();
}
});
【问题讨论】:
-
我不确定你想在这里做什么,你能重新表述一下吗?
-
用户可以从列表中选择。选项 a、b 或 c。用户选择了一个选项。故事通过执行该特定跨度来继续选择的选项,并在消除他们已经选择的选项的同时获得另一组选项。我希望能够以任何顺序执行代码。
-
我正在写一部互动小说
标签: jquery html select options