【发布时间】:2010-11-14 22:27:07
【问题描述】:
我已经解决了大约 90% 的问题,但似乎无法得到最后的 10%:
我有一个要求用户选择位置的表单。在选择时,我希望页面(和请求表单)淡出不透明,并在顶部淡出一个新的 div,其中包含定价信息。
目前,对于第一个选定选项 (novato),一切正常,但在列表中的任何其他选项上,页面和请求表单 div 都会淡出,并且新的定价 div 不可见。
我很困惑,我很确定我只是错过了一些愚蠢的东西(作为一个新手)。任何帮助表示赞赏!
申请表:
<form id="locations">
<select>
<option>Choose a location</option>
<option></option>
<option id="novato" value="novato">Novato</option>
<option id="sanleandro" value="sanleandro">San Leandro</option>
<option id="livermore" value="livermore">Livermore</option>
<option id="sanjose" value="sanjose">San Jose</option>
</select>
<input type="submit" id="submit" value="go"/>
</form>
JS:
> $(function() {
> $("#locations").submit(function() {
> if ($("#novato").attr("selected")) {
> $("#pricing_novato").fadeIn("normal");
> $("#page").fadeTo("normal", 0.1);
> $("#pricing_novato").css({top:"0",left:"50%",margin:"20px
> 0 0 -"+($("#pricing_novato").width() /
> 2)+"px"});
> $("#pricing_selector").fadeOut("normal");
}else if($("#sanleandro").attr("selected")) {
> $("#pricing_sanleandro").fadeIn("normal");
> $("#page").fadeTo("normal", 0.1);
> $("#pricing_sanleandro").css({top:"0",left:"50%",margin:"20px
> 0 0
> -"+($("#pricing_sanleandro").width() / 2)+"px"});
> $("#pricing_selector").fadeOut("normal");
}else if($("#livermore").attr("selected")) {
> $("#pricing_livermore").fadeIn("normal"); $("#page").fadeTo("normal", 0.1);
> $("#pricing_livermore").css({top:"0",left:"50%",margin:"20px
> 0 0
> -"+($("#pricing_livermore").width() / 2)+"px"});
> $("#pricing_selector").fadeOut("normal");
}else if($("#sanjose").attr("selected")) {
> $("#pricing_sanjose").fadeIn("normal");
> $("#page").fadeTo("normal", 0.1);
> $("#pricing_sanjose").css({top:"0",left:"50%",margin:"20px
> 0 0 -"+($("#pricing_sanjose").width()
> / 2)+"px"});
> $("#pricing_selector").fadeOut("normal");
}
});
});
div:
<div id="pricing_novato">content</div>
<div id="pricing_sanleandro">content</div>
<div id="pricing_livermore">content</div>
<div id="pricing_sanjose">content</div>
【问题讨论】: