我曾出这90%左右,但似乎无法得到最后的10%:显示/隐藏的div提交
我有要求用户选择一个位置的形式。在选择时,我希望页面(和请求表单)淡入淡出,而新的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>
哇!真奇怪。我看到你做了什么,仍然无法分辨为什么我会打破。这里是实时链接:http://76.103.255.69/earthcare/Products_residential/index2.aspx – Jenn 2010-11-14 23:04:33
我的猜测是它与样式有关。尝试使用相同的'css(...)'行并添加'position:relative' style - 试验一下,看看是否有问题。 – 2010-11-14 23:07:40
我必须在样式表或我的包含文件中遇到问题,但解决方案正常运行!非常感谢! – Jenn 2010-11-14 23:23:33