【发布时间】:2012-05-26 07:10:50
【问题描述】:
我正在创建的注册表单在选择下拉列表中有商业和住宅选项。
根据活动页面类型,我更改了默认选择的选项。
这是html:
<select class="type_c" name="type_c"> // default selected is business
<option value="Business" selected="selected">Business</option>
<option value="Residential">Residential</option>
</select>
这是我在每个页面的页脚中运行以更改这些值的代码:
$(function(){
var pageType = getPageType(); // returns either 'Business' or 'Residential'
$('.type_c option').each(function(){
$(this).removeAttr('selected');
});
$('.type_c option').each(function(){
if($(this).html() == pageType)
$(this).attr('selected','selected')
});
});
问题在于,当它在“住宅”页面上时,在 DOM 中选择了“住宅”选项,但在视觉上,选择了“商业”选项!
谢谢。
【问题讨论】:
-
进行了编辑以注意这仅在 Firefox 中发生。我在想它总是在发生。